© 2026 Hedgehog Software, LLC
Twitter
GitHub
Discord
System
Light
Dark
More
Communities
Docs
About
Terms
Privacy
Search
Star
Feedback
Setup for Free
How do I disconnect client websocket from a worker? - Cloudflare Developers
CD
Cloudflare Developers
•
15mo ago
Darren
How do I disconnect client websocket from a worker?
I am using the Web socket server example here
https://developers.cloudflare.com/workers/examples/websockets/#write-a-websocket-server
I would like to gracefully disconnect the websocket
. I tried using
server.close();
client.close();
server.close();
client.close();
however
, the client side does not get disconnected
. I am testing with
websocat
websocat
from command line and after the close
(
) calls are invoked
, the connection seems to remain open
(even though no communication comes through
)
.
Is there any way to gracefully indicate the connection closing so that client
's sockets get disconnected at tcp
/ip level
?
Cloudflare Docs
Using the WebSockets API · Cloudflare Workers docs
Use the WebSockets API to communicate in real time with your Cloudflare Workers
.
Cloudflare Developers
Join
Welcome to the official Cloudflare Developers server. Here you can ask for help and stay updated with the latest news
86,942
Members
View on Discord
Resources
ModelContextProtocol
ModelContextProtocol
MCP Server
Similar Threads
Was this page helpful?
Yes
No
Recent Announcements
Similar Threads
Websocket worker
CD
Cloudflare Developers / workers-and-pages-help
14mo ago
websocket-upgrade fetch from worker to DO randomly delayed
CD
Cloudflare Developers / workers-and-pages-help
2y ago
Cloudflare Worker Websocket
CD
Cloudflare Developers / workers-and-pages-help
3y ago
How do I send traces from a worker to Grafana Tempo?
CD
Cloudflare Developers / workers-and-pages-help
2y ago