Closed lanner17 closed 8 months ago
Hi, first of all 1.4.1 is an old version and I would strongly recommend to update it (please read https://github.com/TooTallNate/Java-WebSocket/security/advisories/GHSA-gw55-jm4h-x339)
I'm not sure what you mean here, do you want the GOING_AWAY event to not close the socket? Otherwise, why not free resources in onClose?
@PhilipRoman Thanks for the recommendation to upgrade - made a note to upgrade.
Indeed, I want to close the socket when there is a GOING_AWAY event. I expected that onClose() will be called when the client navigates away so that I can free resources when onClose() is called. However, onClose() is not being called when GOING_AWAY occurs - at least as far as I can tell (I am using v1.5.6).
Basically, I would like to find a way to detect when a client goes away, to free up resources that it created.
Cannot reproduce, for me connection is closed correctly when I navigate away from a HTML page (1001) or close the tab (1006). You can confirm with Wireshark that a close packet is indeed sent. It should look like this: If you see this packet, but no close event is generated, then it is indeed a bug.
Alternatively, you can set the connection lost timeout to something lower than default (https://github.com/TooTallNate/Java-WebSocket/wiki/Lost-connection-detection) and then any socket will be cleaned up in reasonable time, even if it doesn't disconnect properly.
@PhilipRoman Apologies for the delay. I agree, browsers do close the web socket if you navigate away or close the tab/page. The case I was thinking about is when a program has a handle to a web socket and then open another one with the same handle without closing the previous one. I assumed the first one will time out after a while. However, using a tool to look at the TCP statuses, one can see that the connection stays established, hence it will not time out. However, both sockets will close when one navigates away or close the page. It was a wrong assumption on my end. Thank you for the response
Hi In my websocket server application, clients navigate away from the server all the time. I assume the "event"
GOING_AWAY
is generated when this happens. I would like to release resources in the server when this happens. However, it does to seem thatGOING_AWAY
fires theonClose()
message in the server. Is there another way to trap theGOING_AWAY
event ? (It is version 1.4.1)Thank you