Delay at .onclose event with my websocket

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!!!
Was this page helpful?