9 months ago
Project: 4b640aaa-c1cf-41f3-8d70-c353abfa1bc2
Building a collaborative editor (NextJS + Lexical + y-redis) on Railway. WebSocket connections fail with code 1006 in production but work perfectly locally.
The Problem
✅ Auth works - HTTP 200
✅ WebSocket upgrade completes
✅ Connection opens
❌ Immediately closes with 1006 when server sends initial Yjs sync messages
Error Details
🔗 WebSocket connection opened for user: {...}
📤 Sending SyncStep1...
❌ WebSocket connection closed: { code: 1006, reason: 'abnormal closure' }
HTTP: 499 "client closed request before server response"Railway Context
Confirmed Railway WebSocket bug reported June 20th with identical symptoms. Railway claimed it was fixed, but still experiencing it.
What I've Tried
✅ Disabled compression (
uws.DISABLED)✅ Reduced timeout to 30s
✅ Added delays before sync messages
❌ Still fails when sending binary Yjs data
My Theory
Railway's proxy has issues with binary Yjs protocol messages. Connection opens fine, but terminates when sending sync data.
Questions
Anyone else having Railway WebSocket issues?
Alternative hosting for WebSocket-heavy apps?
Tried both US West/East region, region issue?
Disabled RailwayMetal Edge, maybe thats the problem?
// Works locally, fails on Railway
app.ws('/:room', {
compression: uws.DISABLED,
idleTimeout: 30,
// ...sends binary Yjs sync messages
})Blocked for 3+ days on this! Any help appreciated 🙏
websockets #yjs #lexical
1 Replies
9 months ago
according to my brief research your theory is correct, i had similar issues with processes been terminated abruptly, with sidekiq, a background job gem, in rails so i moved my code to fly.io and kept the databases, postgres and redis here.