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

In Firefox, connection .... was interrupted while the page was loading

Open selay opened this issue 11 years ago • 42 comments

Hi, it shows connection to ws:..... was interrupted while the page was loading in Firefox but works. I saw many possible fix suggestions on different sites but none of them work now. It works fine in other browsers without any error/warning in the console. I am using socket.io 1.3.4 and firefox latest version 35.0.1.

selay avatar Feb 21 '15 00:02 selay

Same here, random disconnect on firefox, not on chrome. I can't understand what is the problem.

oxhak avatar Feb 28 '15 21:02 oxhak

It still happens on the latest version 1.3.6

selay avatar Aug 04 '15 23:08 selay

There's an open ticket for this on Bugzilla. The "workaround" doesn't work for me.

arusahni avatar Aug 19 '15 17:08 arusahni

This will fix it window.onload(function() { //code goes here });

ghost avatar Aug 22 '15 13:08 ghost

Issue is still alive apparently getting the exact same error, I've tried both versions 1.2.0 I believe and the one that comes with the latest NPM package. Any workarounds?

1989x avatar Mar 17 '16 23:03 1989x

I too am getting the same error in Firefox. Can't seem to find a fix anywhere.

UndergroundLabs avatar Mar 19 '16 14:03 UndergroundLabs

I'm getting this error in FF 45 and my websocket connection times out.

chchrist avatar Apr 19 '16 11:04 chchrist

I am getting this error on FF 46 + Mac, FF 45 + Windows 10.

maxpaynestory avatar Apr 29 '16 13:04 maxpaynestory

For us the problem was the version of the net scaler we used

chchrist avatar Apr 29 '16 14:04 chchrist

Are you referring to the python script net scaler? I am not using it and still getting this error on socket.io

maxpaynestory avatar Apr 29 '16 14:04 maxpaynestory

Had the same issue on OS X 10.11.5 and Firefox 47. With the following configuration it works without errors for me on Firefox 47 and Chrome 51.0.2704.103.

package.json

{
  "name": "socket-io-test",
  "version": "1.0.0",
  "description": "socket io test",
  "main": "app.js",
  "scripts": {
    "start": "node app.js"
  },
  "repository": {
    "type": "git",
    "url": ""
  },
  "keywords": [],
  "author": "Aleksandar Gotev",
  "license": "ISC",
  "homepage": "",
  "dependencies": {
    "express": "^4.14.0",
    "socket.io": "^1.4.8"
  }
}

config.json

{
    "process_title": "wstest",
    "web_server_port": 3000,
    "max_seconds_to_wait_on_kill": 3
}

app.js

var expressFramework = require('express');
var express = expressFramework();
var fs = require('fs');

//read configuration
var configuration = JSON.parse(fs.readFileSync('config.json', "utf8"));

//setup express
express.set('json spaces', 2);
express.disable('x-powered-by'); //disable express framework credits
express.use("/", expressFramework.static(__dirname + "/static")); //serve static files

//start web server
var webServer = express.listen(configuration.web_server_port, function () {
    console.log("Web server listening on port " +  configuration.web_server_port); 
});

//setup socket.io
var io = require('socket.io')(webServer);
io.on('connection', function (socket) {
    socket.emit('hello', {
        msg: "hello"
    });
});

//setup process
var killHook = function killHook() {
    console.log("Detected kill signal");

    webServer.close(function() {
        console.log("Graceful shutdown");
        process.exit(0);
    });

    setTimeout(function () {
        console.log("Waited for " + configuration.max_seconds_to_wait_on_kill + " seconds. Force kill.");
        process.exit(0);
    }, configuration.max_seconds_to_wait_on_kill * 1000);
};

process.title = configuration.process_title;
process.on('SIGTERM', killHook);
process.on('SIGINT', killHook);

static/index.html

<html>
<head>
    <title>WS Test</title>
</head>
<body>
    <script src="/socket.io/socket.io.js"></script>
    <script>
    window.onload = function() {
        var socket = io.connect('http://localhost:3000');

        socket.on('hello', function (data) {
            document.write("<p> Hello message: " + JSON.stringify(data) + "</p>");
        });

        window.addEventListener("beforeunload", function() {
            console.log("Close web socket");
            socket.close();
        });
    };
    </script>
</body>
</html>

Just recreate the files in a directory and then execute:

npm install
npm start

And head your browser to http://localhost:3000

gotev avatar Jul 15 '16 12:07 gotev

Hi all, I was having the same issue.. By using socket io 1.0.* my errors fixed . Hope this helps.

nagarjunbn avatar Aug 20 '16 07:08 nagarjunbn

Any updates on this? Because this is issue also affects Firefox 51.0.1

nottherealbatman avatar Feb 01 '17 15:02 nottherealbatman

I get the same error but the connection works perfectly, strange...

wirespecter avatar Mar 02 '17 16:03 wirespecter

Set network.notify.ipv6 to false.

fschiefelbein avatar Aug 01 '17 23:08 fschiefelbein

still an issue on firefox quantum release

bovas85 avatar Dec 04 '17 14:12 bovas85

@nagarjunbn It actually does resolve the issue for me as well. I used the latest socket.io available: "socket.io": "2.0.4"

and the below issue is gone: The connection to http://localhost:55542/dist/__webpack_hmr was interrupted while the page was loading.

shaukatwaqarangular avatar Dec 07 '17 16:12 shaukatwaqarangular

Still getting this error with 2.0.4, Firefox Quantum (58.0), macOS 10.12.6:

The connection to http://localhost:4000/__webpack_hmr was
interrupted while the page was loading.

andreasvirkus avatar Jan 30 '18 13:01 andreasvirkus

FF Quantum is sending a PING. Is there a socket.io handler implementation for WebSocket ping/pong? Could this be the issue?

cigzigwon avatar Jan 30 '18 15:01 cigzigwon

This error suddenly popped up in my Vue project when starting to use vuetify. Firefox 59.0.2 (64-bit) on Ubuntu. No errors in Chrome. A bit later the error changed to: Firefox can’t establish a connection to the server at http://localhost:8080/__webpack_hmr.

dizid avatar Apr 01 '18 21:04 dizid