WebSocket in Firefox makes two connections

I am encoding a WebSocket server in Java. When I use WebSocket to connect to the server in firefox, I find that two connections are established, and one of them never sends any data ...
My version of firefox is 15.0.1
The same code that runs in Chrome is fine, Once connected, established only one connection.
Does anyone have such problems?

There is a server code:

ServerSocket svrSock = new ServerSocket();
svrSock.bind(new InetSocketAddress("0.0.0.0", 11111));
while(true) {
    try {
        // accept connection
        Socket clientSock = svrSock.accept();
        // print the socket which connected to this server
        System.out.println("accept socket: " + clientSock);

        // run a thread for client
        new ClientThread(clientSock).start();
    } catch (Exception e) {
        e.printStackTrace();
    }
}

And there is js code:

var url = 'ws://localhost:11111/test/';
var ws = new WebSocket(url);
ws.onopen = function(){
    console.log('connected!');
    ws.send(11111);
    ws.close();
};
ws.onclose = function(){
    console.log('closed!');
};

When I run this js code in firefox, I get this on my server console:

accept socket: Socket [addr = / 127.0.0.1, port = 56935, localport = 11111]
accept socket: Socket [addr = / 127.0.0.1, port = 56936, localport = 11111]

+5
1

Firefox 15, ​​ firefox 16: https://bugzilla.mozilla.org/show_bug.cgi?id=789018

Firefox 15 , HTTP/SPDY, WebSocket - HTTP 1.0 ( 1.1), .

, , .

+4

All Articles