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.
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.