Websockets keep disconnecting for sites proxied via Cloudflare

We proxy websockets for many sites through Cloudflare. Something I’ve noticed consistently is that websockets via Cloudflare will eventually be disconnected, usually within the first day - but often within hours - for no clear reason. The ping timeout on the server is less than 100 seconds, since that’s Cloudflare’s limit. It was 80 seconds but I cranked it down as low as 40 and this is still happening just as often, so I don’t think the issue is TCP or websocket timeout.

In contrast, if I access the application directly, without going through Cloudflare, the issue doesn’t happen at all. The websocket will stay up forever, essentially.

The only other explanation I can find is that Cloudflare periodically reboots servers and this will close active connections, but I find it hard to believe that would be happening several times per day.

Could an engineer confirm roughly how frequently users can expect to see Websockets forcibly disconnected, and under what other circumstances the connection could be closed? This has been happening for months and despite extensive debugging, we are not any closer to finding the cause of these disconnects. If anyone else has noticed this and has been able to resolve, would love to know what you did to fix that - thanks!

Cloudflare doesn’t give fixed numbers, only this…

This thread hints at where the levels may roughly be…

Can you clarify what you mean by “levels”?

I’ve noticed this happening with as few as just 1 concurrent Websocket, so it’s not a rate limiting thing at all. That websocket will just eventually be disconnected, if it goes through Cloudflare, and the timing is not consistent at all. I’ve tried for months to discern a pattern, only to conclude there is no reliable pattern to when disconnects occur (e.g. amount of time since last ping, total time since connection started, etc.)

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.