Socket.IO in a Node app

I have been trying out the free tier of Web Services and I have a Node application that uses Socket.io. However, I am having a problem that my websocket connection automatically gets closed exactly after 5 minutes of inactivity.
Although when I run the same server on Localhost I can stay connected for as long as I want and the connection doesn’t get automatically closed.

Is it some sort of Timeout that has been set by default on free web services? I am hesitant to upgrade to a paid tier if this problem still persists.

Hi @AestheticallyAsthmat,

Our free tier services do automatically spin down after 15 minutes of inactivity. However, if you are seeing this after 5 minutes, that does seem a bit premature. Please feel free to DM me with the details of your service and we’ll be happy to take a closer look.

I seem to have the same issue, after about 5 minutes on the Free Tier (the server is active during that time) my open web sockets get closed. I just transferred my app from Heroku and I didn’t see this issue over there so I’m sure it’s not my code/application.

I’m going to try using a library like this to reconnect when the web socket is closed: GitHub - pladaria/reconnecting-websocket: Reconnecting WebSocket. For Web, React Native, cli (Node.js)

my websocket connection automatically gets closed exactly after 5 minutes of inactivity.

I can confirm this behavior.

after 5 minutes of inactivity.

It’s not even if inactive. It seems to be being closed no matter what.

Plain node.js websocket server app in my case.

Hi,

We have confirmed there is an open issue that causes long-running connections, such as websockets, to timeout on the free tier. We will update this thread once this limitation has been resolved. Very sorry for the trouble here!

Chiming in to say I ran into this today as well, takes only about 5 minutes to timeout.

I have a similar problem. I am using Socket.io with Nuxt 3. The WebSocket works great on the local server but on Render it doesn’t work. It throws an error of web socket error.

Jake says this is a limitation of the free tier here:

It’s happening to me, too. This is very clearly deliberate. Socket connections are dropped after exactly 5 minutes regardless of activity. It would be very nice to add this to the documentation.

This issue is still persistent even for paid plan. My app basically depends on this functionality to do most everything could you please help me out on this.

So you decided that a running websocket interaction is “inactivity”

It is technically not that.