10 months ago
I noticed my websocket connection randomly closing so I added the code below to see if its throwing an error. Here's what I found, but I am unsure if its related to Railway or not.
const wsTransport = new WebSocketTransport(); // Accepts optional parameters
const wsClient = new SubscriptionClient({ transport: wsTransport });
wsClient.transport.socket.addEventListener("open", () => {
console.log("WebSocket connection established.");
});
wsClient.transport.socket.addEventListener("close", () => {
console.log("WebSocket connection closed.");
});
wsClient.transport.socket.addEventListener("error", (error) => {
console.error("WebSocket error:", error);
});NetworkError: failed to connect to WebSocket: Didn't receive h2 alpn, aborting connection
11 Replies
10 months ago
Hey, afaik Railway implements timeouts on connections made via Public Networking, make sure to implement a reconnection logic to prevent that.
I did end up implementing reconnection logic, but are you saying that error is a result of timing out?
10 months ago
pretty sure it is, I was also getting the same problem and from my tests Railway would drop the connection every 4-8 hours but also depends if they're doing some kind of hardware upgrade
Hmm… I added reconnection logic and it kept dying getting blocked by this same network error. I'm thinking I might just have to let the server error and have it restart
9 months ago
what is the time span from connection established to dying?
Okay, i just got it again, so it was a lot longer of a time span.
This happens, but i am unsure why it happens still.
My server gets into a real weird state when this happens. Right now, the server says "Crashed" whcih was like 6 min ago, but the server is also still running becuase I see new logs coming in.
I think 1. might be related to the socket provider's infra, but 2. is definitely strange
8 months ago
I think #2 is related to us restarting the container but not marking it as running again. If you can provide a reproducible example, that would be most helpful.

