Firefox reporting errors on page leave/reload

5,625 views
Skip to first unread message

The Yak

unread,
Sep 27, 2012, 1:22:13 PM9/27/12
to sock...@googlegroups.com
When connected to socket.io in Firefox, an error is produced every time I leave the page.

The connection to ws://xxx/ocket.io... was interrupted while the page was loading.

Does anyone know how to disable this error? It's very annoying with Firebug installed as a little icon flashes when the error occurs.

Milan Babuskov

unread,
Sep 28, 2012, 6:39:34 AM9/28/12
to sock...@googlegroups.com

I see the same issue. When page is closing it Firefox disconnects the client just before it's closed and then socket.io tries to reconnect.

Since I initiate page close via javascript I tried socket.disconnect() and socket.close(), but it does not help.

It would be nice to have some solution to this problem.

M.

Arnout Kazemier

unread,
Sep 28, 2012, 7:05:08 AM9/28/12
to sock...@googlegroups.com
Did you try to shutdown the connection during unload or beforeunload?

Milan Babuskov

unread,
Sep 28, 2012, 3:27:19 PM9/28/12
to sock...@googlegroups.com
On Friday, September 28, 2012 1:05:58 PM UTC+2, 3rdEden wrote:
Did you try to shutdown the connection during unload or beforeunload?

Even before any of those. I have a button on the screen that says "Leave game" with the following code:

<input type="button" onClick="leavePage();" name="Leave page">

function leavePage()
{
    socket.disconnect();
    document.location = '/menu.html';
}

That did not work. Maybe I should use something else and not socket.disconnect()? I find socket.io docs lacking regarding closing the connection on the client side. Even googling does not help much.

Thanks,
M.

The Yak

unread,
Oct 1, 2012, 2:34:30 PM10/1/12
to sock...@googlegroups.com
I'm going to chalk this up to a FireFox issue. I have confirmed that socket.io is appropriately calling the websocket.close() function when adding a disconnect in onbeforeunload. My guess is it just takes time for Firefox to properly close the socket and it takes longer than the page reload/change. (Just a guess.)

If I do not have Firebug enabled for my site or do not have the option for show error count checked in Firebug, then I'd never notice the issue.
Reply all
Reply to author
Forward
0 new messages