Websocket connection closes with error code 1006

When connecting to my websocket server with cloudflare, I get disconnected about 30 seconds after my connection. I can then reconnect, and same thing happens again and again.

I do not have this error when connecting to my localhost server.

Both servers use the same code and has the exact same behaviour, but my server via cloudflare disconnects randomly.

Has anyone else experienced this? And any suggestions on how i may fix this?

Thank you.

It was nothing with cloudflare, but with GKE.

Hi there, I am facing similar issue and mentioned solution and details with steps here: