Websockets disconnecting frequently

Hi,
I’m using Websockets (Socket.io) in my web application. The WebSockets get disconnected frequently (mostly every 30-40 seconds. However, they can sometimes hold the connection open for longer such as 3-4 minutes). When running my application locally, it works with no disconnections. After some debugging, I concluded that the issue is the hosting environment (or something in between, such as proxies) - something disconnects the connection on purpose rather than an application or network error.

Is it the intended behavior of Websockets with Koyeb?


Some other details:

  • Migrated from Heroku.
  • Application is Node.js back-end and Angular front-end (the front-end is hosted by a different provider - Cloudflare).
  • The disconnect error code (front-end) is 1005 or 1006 (I couldn’t yet figure out when which error gets emitted).
  • Tried lowering the ping interval to 10 seconds, however, regardless of the pings, the connection sometimes gets disconnected some milliseconds after I sent or received a message (not a ping one). So it rules out disconnections due to inactivity.
  • Couldn’t see any error on the server side (Koyeb) in my application run-time logs besides that the WebSocket gets disconnected.
1 Like

Hi!

Thanks a lot for the report. We’ve started investigating the issue and reproduced the disconnections you observed.
We’ll get back to you soon with more details :slightly_smiling_face:

Hi!

Thank you for the swift response, glad to know that this is indeed not the intended behavior as my app focuses heavily on WebSockets.

Are there any updates?

Hey @neyney10,

The TLDR is that we currently have a 120sec timeout on all connections, it doesn’t distinguish between idle and active connections, which is not the intended behavior.

We fixed the issue on most of our infrastructure but our global load balancer still doesn’t behave as we would like it to.

We aim to release a fix in early December.

Hi @yann,
Has this fix been implemented? I still experience these same issues.
Thank you

Hi @Andrea_De_Masi,

We have not implemented a fix for this yet. We’ll update this topic as soon as we have a realistic ETA for this fix.

I’m curious, what is your use case with WebSockets?

Hi @alisdair,
thank you for the update!
I’m developing an open-source browser extension that uses WebSockets for real-time, low-latency communication. In syncing two clients, connection reliability and latency play a significant role in the main logic.

1 Like

Hey @Andrea_De_Masi,

That’s exciting!

We’re currently working on improvements to our load-balancing layer to support gRPC, I will check to see if we can solve the WebSockets timeout issue in the continuity of this improvement.

I created an entry on our feedback platform to make sure we prioritize the timeout fix for WebSockets shortly.

2 Likes

Hello,

We just released a patch for the excessive WebSockets disconnections, let us know how this work on your side.

Thanks for your support.

Bastien

2 Likes