#Delay at .onclose event with my websocket

8 messages · Page 1 of 1 (latest)

pearl hearth
#

Ok so, when the websocket connection ends i need to execute some code in onclose event in server-side and client-side in that instant, but when cloudflare ends the connections at restart their servers, the onclose event isn't executed correctly, it takes like 10 seconds in execute and sometimes it never execute.
I removed all timeouts from my nginx restart and I still with this issue, please help me!!!

brittle flare
#

It sounds like you're not actually closing the frames, you're just timing them out?

#

If that's the case, then the state of the connection is determined by whether a PING is replied with PONG or not, and those PINGs are not done constantly, usually the interval is 20 seconds or such.

pearl hearth
brittle flare
#

But that is not a graceful exit, that's a timeout.

pearl hearth
brittle flare
#

For a websocket to be closed gracefully, a close frame must be either sent and received, or received and sent. Otherwise, it will result in a timeout after x time.