socket.io icon indicating copy to clipboard operation
socket.io copied to clipboard

Socket interrupted in v0.8.6 and Firefox 7.0.1

Open kellishaver opened this issue 15 years ago • 19 comments

I'm getting errors creating the web socket in Firefox 7.0.1 - I've tried to make the example as basic as possible. Here we go....

Environment:

OS X Lion (server and client)
Firefox v7.0.1
Node v0.4.11
Socket.io v0.8.6

Console Error:

The connection to ws://home:3000/socket.io/1/websocket/10796925721352367974 was interrupted while the page was loading. http://home:3000/socket.io/socket.io.js Line 2294

NodeJS Output:

node server.js
    info  - socket.io started
    debug - served static content /socket.io.js
    debug - client authorized
    info  - handshake authorized 10796925721352367974
    debug - setting request GET /socket.io/1/websocket/10796925721352367974
    debug - set heartbeat interval for client 10796925721352367974
    debug - client authorized for 
    debug - websocket writing 1::
    debug - websocket writing 5:::{"name":"welcome","args":[{"hello":"Hello."}]}
    info  - transport end
    debug - set close timeout for client 10796925721352367974
    debug - cleared close timeout for client 10796925721352367974
    debug - cleared heartbeat interval for client 10796925721352367974
    debug - discarding transport

server.js

var io = require('socket.io').listen(3000);

io.sockets.on('connection', function (socket) {
    socket.emit('welcome', { hello: 'Hello.' });
});

test.html

<!DOCTYPE html>
<head>
    <title>Server Test</title>
    <script src="http://home:3000/socket.io/socket.io.js"></script>
    <script>
        var socket = io.connect('http://home:3000');
        socket.on('welcome', function(data) {
            document.write(data.hello);
        });
    </script>
</head>
<body>

</body>
</html>

Any help would be appreciated. Thanks!

kellishaver avatar Oct 30 '11 20:10 kellishaver

Are other browsers, such as Chrome 14+, working ok with the same example?

einaros avatar Oct 30 '11 21:10 einaros

Sorry, yes. I meant to mention that. Chrome works fine.

kellishaver avatar Oct 30 '11 22:10 kellishaver

Ok, that's strange. Are you running any particular addons for FF?

einaros avatar Oct 31 '11 09:10 einaros

Nothing that should interfere with this, I wouldn't think.... Web Developer, Firebug, Rainbow, and ScreenGrab.

kellishaver avatar Oct 31 '11 10:10 kellishaver

Never heard of Rainbow, but I'll take your word for it. Are you running any particular firewall or antivirus software?

einaros avatar Oct 31 '11 11:10 einaros

It's an eyedropper/color picker.

Nope, nothing as far as firewall or antivirus.

I did some more poking around. If I comment out the "socket.on('welcome'....)" function in the client code and leave only the "socket = io.connect(...)" line, I don't get the error and Firebug shows the following request:

GET http://home:3000/socket.io/1/?t=1320059543966 200 OK

With the response:

 1709344179350188626:15:25:websocket,htmlfile,xhr-polling,jsonp-polling

And the server doesn't hang with the 'discarding transport' error.

kellishaver avatar Oct 31 '11 11:10 kellishaver

Sneaky typo in my previous post .. "take your work for it" would be a horrible thing for me to do.

Anyhoo, there's nothing wrong with your example code, so this really shouldn't happen. I haven't installed Lion on my Mac, but I could always check the latest master with the same code on my snow leopard + ff 7.0.1 when I get home from work.

einaros avatar Oct 31 '11 12:10 einaros

Thanks. :)

I'll install it on my Ubuntu server later and have a go. At least then maybe we can determine if the problem is Firefox + Lion or Node/socket.io + Lion, since I have the server and client both running on the same machine at the moment.

kellishaver avatar Oct 31 '11 12:10 kellishaver

OK, I get the same thing with the server running on Ubuntu. So using Lion as the server environment isn't the issue.

kellishaver avatar Oct 31 '11 17:10 kellishaver

Wow, and now I feel like the world's largest idiot.

I had restarted Firefox several times and it made no difference - the error would still occur, but after rebooting the computer, the problem has disappeared.

So it sounds like either Firefox or Lion (more likely Firefox, I would imagine) encountered an error somewhere and then didn't clean up properly.

I shall now close this and hide in the corner.

kellishaver avatar Nov 01 '11 04:11 kellishaver

@kellishaver , Though you have closed the issue, I'd like to add that document.write must have caused this. I just hit this issue.

pdvyas avatar Apr 09 '12 19:04 pdvyas

@pdvyas Are you on Lion too? I'm trying to find a pattern here. I'm having that exact issue.

Of course, I will now restart my computer, which means that I'll very likely stop hitting this bug (and that I won't be able to dig this bug further).

I don't use document.write, though.

espadrine avatar Apr 16 '12 16:04 espadrine

@pdvyas Do you have any more information on that issue? I am having it right now and a reboot of the computer did not help.

By the way, is this issue Mac-specific?

espadrine avatar Apr 16 '12 18:04 espadrine

@espadrine I am on Lion. This fails on Firefox. My issue was that, after receiving the first message, the socket broke and the browser was trying to load something ( which is precisely what the error says, I guess ). As I was testing, I was using document.write , not using it made my testing successful. What is your code ?

pdvyas avatar Apr 17 '12 10:04 pdvyas

@pdvyas Here's the webpage.

I have grep'ed all the JS I use, nowhere is there a single document.write.

espadrine avatar Apr 17 '12 12:04 espadrine

@espadrine It seems that there is something broken in your code as even the client side library is not getting loaded. To check with the browser compatibility, etc, try making a trivial app (outside the framework you are working on).

pdvyas avatar Apr 17 '12 17:04 pdvyas

@pdvyas You're right! It is a firefox issue, not a socket.io issue.

espadrine avatar Apr 17 '12 18:04 espadrine

I'm on Lion as well with Firefox. The only time I get this message is when I click a link that requires a page refresh but the majority of the links on my site are ajax so its not too noticeable of an error. It always happens when I require a page refresh though.

sebringj avatar Oct 05 '12 15:10 sebringj

I have the same problem too!

joychin avatar Apr 15 '13 06:04 joychin