WebSocket connections dropping silently after ~50 minutes
aiotronic-pe
PROOP

a month ago

I'm running a NestJS application on Railway (Pro plan, us-east4 region) that maintains a persistent WebSocket connection to an external service. The connection drops silently after approximately 50 minutes with no events, no errors, and no logs — the process keeps running normally but the WebSocket is dead.

This does not happen when running the same application on a local server. I suspect there may be a TCP idle timeout or network policy in Railway's infrastructure that's killing idle connections around that threshold.

Could you confirm if there's any idle connection timeout configured at the network level, and if there's a way to increase or disable it?

$20 Bounty

2 Replies

Railway
BOT

a month ago

This thread has been marked as public for community involvement, as it does not contain any sensitive or personal information. Any further activity in this thread will be visible to everyone.

Status changed to Open Railway about 1 month ago


euphoriuhhh
FREE

a month ago

have you tried to add a ws.ping() call on a 20-second interval to keep the connection alive?


a month ago

We don't advertise or guarantee any specific duration for WebSocket connections, so your application should not be written with a particular timeframe in mind. The recommended approach is to use a WebSocket connection pool with multiple connections and staggered recycle times, so you always have available connections to multiplex data over for resilience.


Welcome!

Sign in to your Railway account to join the conversation.

Loading...