Websocket disconnections

We currently have a chat site which uses Websockets but for some reason we are experiencing disconnections every 5 minutes or so. I don’t think this is a server side issue but the problem might be with Cloudflare protection layer. Is there a workaround on this at? Any help would be great. Thanks.

See:

https://news.ycombinator.com/item?id=11641496

Cloudflare does machine config updates and restarts extremely often, so when it does it sends a 1001 Going Away to both the websocket server and client. Your client should handle this and immediately reconnect. See how Discord deals with this by using session IDs: https://discordapp.com/developers/docs/topics/gateway#resuming