Firefox Websocket connection does not close after closing tab or browser

I tested the connection in google chrome browser, connecting and disconnecting is ok, but why doesn't firefox close the connection after closing it?

I tried to add this piece of code:

$(window).on('beforeunload', function(){
    ws.close();
});

      

but it didn't help, are there any other hacks to solve this?

Also I tried on the server side:

byte d = bytes[0]; //first byte
if(d == 0x8)
{
   System.out.println("DISCONNECT");
}

      

but didn't help, other hacks?

+3


source to share





All Articles