codeminders / socket.io-server-java

Java Backend for Socket.IO (http://socket.io/)
36 stars 18 forks source link

xhr-polling sessions do not seem to honor timeout and at the same time, have unbounded internal message queue #23

Open vkurland opened 4 years ago

vkurland commented 4 years ago

... which can easily lead to a memory-leak-like behavior if the client opens session using xhr-polling but does not actually poll.

I set the timeout in the onConnect() listener:

            socket.on(this);  // attach onDisconnect listener
            socket.getSession().setTimeout(Duration.ofSeconds(30).toMillis());

Please advise if I should set timeout differently. At the very least, the queue com.codeminders.socketio.server.transport.XHRTransportConnection#packets should probably have limited capacity. Maybe even the session could disconnect when the queue becomes full because that means the browser does not read messages