I see that the worker websocket is

I see that the worker websocket is closing the connection every roughly 4.5 mins. Whats the deal with this? I've not run across any documentation which has some information on some kind of timeout.
No description
7 Replies
Alex
Alex•3w ago
Are you sending any data over the connection? I am trying to see where it's exactly coming from. But WebSockets usually have some inactivity timeout. It might come from the client or the server (or both) and is usually solved by sending ping/pong messages at a regular interval.
zehawk
zehawkOP•3w ago
No, its a completely idle test. Nothing happening from the client (that's why I tried on Postman as well to remove any dependencies). As a control, I did multiple tests with echo.websocket.org - that timesout at around 45mins+.
No description
zehawk
zehawkOP•3w ago
So it seems to be a timeout on CF side, so that begs the questions (a) why is it so low? (b) where's the doc on this (c) is it controllable? When I do the test with wrangler dev --remote, the timeout is consistently 1 min
boop
boop•3w ago
Try this https://developers.cloudflare.com/durable-objects/api/state/#setwebsocketautoresponse Note that you will have to manually send these application level pings from your client
zehawk
zehawkOP•3w ago
Yup, thanks, thats what I'm adding now to see how the behavior changes So yes, sending any random WS message at 4min intervals prevents the timeout. I assume that the DO has to keep waking up to handle this, and to prevent that I should use setWebSocketAutoResponse. Is there a working example for this method since the doc leaves a lot to be desired.
boop
boop•3w ago
See this thread: #Hey 👋 I have a DO based off of this
zehawk
zehawkOP•3w ago
@boop you are a star, TY for pointing me to exactly what I needed.

Did you find this page helpful?