Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jetty-users] WebSocketListener.onWebSocketClose called numerous times

I see you have a 1 hour idle timeout at the server side.

That's nice and all, but if you have clients connecting over mobile networks you'll have to contend with intermediaries with their own TCP idle timeouts. (quite common)

I've seen mobile networks close idle TCP connections due to idle timeout.
I've seen SIM cards with configurations to close idle TCP connections that last too long.
I've seen specific mobile towers close idle TCP connections that last too long.
I've seen overloaded mobile networks close idle TCP connections.

If the mobile network idle times out, and you don't send any traffic on that connection from the server side, you won't know about it until the server idle timeout triggers.

You'll want to make sure your program is aware of client reconnects and whatnot, usually you see that as a result of a mobile device.
It can even happen with a mobile device moves from network to network.

I would recommend not relying on the 1 hour idle timeout to cleanup your dead connections.

Instead, use the websocket protocol's ping/pong after a period of time to ensure the other side is still there.
I would use ping/pong frequency faster than 5 minutes. (no more than 5 minutes between ping send).
Why 5 minutes?  Well, that's the most common mobile network TCP idle timeout I've personally encountered (its even a common idle timeout seen on the cloud providers own load balancers: google, aws, azure, etc.  which on some providers you cannot increase, only decrease).

Joakim Erdfelt / joakim@xxxxxxxxxxx


On Fri, Feb 26, 2021 at 10:51 AM Alexander Farber <alexander.farber@xxxxxxxxx> wrote:
Thank you for your suggestion, Joakim, I didn't think about it.

So I have added the remote port to the log (and also upgraded to Jetty 9.4.37.v20210219) 

and yes - the ports are different (please see the log below)... but how can a single user have so many connections (over a dozen) open to my game which requires a single connection only? 

What is the explanation? Some buggy browser (my players are from Russia) or too many tabs?

qtp100555887-17: onWebSocketClose: hostname=77.111.247.123 port=13533 mUid=18555 statusCode=1006 reason=Disconnected
qtp100555887-34: onWebSocketClose: hostname=77.111.247.123 port=55271 mUid=18555 statusCode=1006 reason=Disconnected
qtp100555887-71: onWebSocketClose: hostname=77.111.247.123 port=33979 mUid=18555 statusCode=1006 reason=Disconnected
qtp100555887-17: onWebSocketClose: hostname=77.111.247.123 port=58969 mUid=0 statusCode=1006 reason=Disconnected
qtp100555887-54: onWebSocketClose: hostname=77.111.247.123 port=56049 mUid=18555 statusCode=1006 reason=Disconnected
qtp100555887-34: onWebSocketClose: hostname=77.111.247.123 port=37309 mUid=0 statusCode=1006 reason=Disconnected
qtp100555887-54: onWebSocketClose: hostname=77.111.247.123 port=52163 mUid=18555 statusCode=1006 reason=Disconnected
qtp100555887-17: onWebSocketClose: hostname=77.111.247.123 port=59447 mUid=0 statusCode=1006 reason=Disconnected
qtp100555887-66: onWebSocketClose: hostname=77.111.247.123 port=40691 mUid=0 statusCode=1006 reason=Disconnected
qtp100555887-71: onWebSocketClose: hostname=77.111.247.123 port=42557 mUid=18555 statusCode=1006 reason=Disconnected
qtp100555887-71: onWebSocketClose: hostname=77.111.247.123 port=57649 mUid=18555 statusCode=1006 reason=Disconnected
qtp100555887-71: onWebSocketClose: hostname=77.111.247.123 port=15239 mUid=18555 statusCode=1006 reason=Disconnected

Thank you
Alex
_______________________________________________
jetty-users mailing list
jetty-users@xxxxxxxxxxx
To unsubscribe from this list, visit https://www.eclipse.org/mailman/listinfo/jetty-users

Back to the top