So I have server receiving wss connections in Java hosted on google kubernetes engine.
The client connects to the server and works fine sometimes, but sometimes it fails to connect at all, doesn’t get to the on open event or anything. To see if its server-side or client-side issue I made a small java app that connects to the websocket and had it run overnight doing 30 connections at once and it didn’t have any problems so I think its something client side, or related to sessions keeping something cached.
Sometimes its very “sticky” once you don’t connect once, even if you try to reconnect a million times it won’t work, but if you use a different browser, or reset your wifi it will start working again? Also soon as the server restarts it usually works okay, but after a little while (hours or next day) it won’t work.
One of the strangest behaviors is that if I inspect the request in firefox’s network tab and do “edit and send” on the headers it will ALWAYS work even if the page “stuck” not working no matter how much I refresh. Here is a pic of what I mean:
this always works
The java websocket library I’m using is this one: https://github.com/TooTallNate/Java-WebSocket
var wsocket = new WebSocket(address);
All I want is a consistent connection. I even tried to right code to retry the connection if it doesn’t happen after a certain time, but because of the “sticky” behavior that doesn’t help much.
Here is a screenshot of wireshark info, I don’t really know what any of it means but maybe it can help you guys: wireshark
I feel like it has something to do with the browser/server keeping a session history or something?
On the server I get the following error at least some of the time when this occurs:
The connection was closed because the other endpoint did not respond with a pong in time.