That is not normal.
I am using Chrome 24 on Ubuntu with the following test code (just fire up Chrome Dev console and paste it in):
function test_ws(uri){
start = new Date().getTime();
ws = new WebSocket(uri);
ws.onopen = function(){
console.log("onopen of", uri, "in", (new Date().getTime() - start), "ms");
};
}
Here are some average results I've gotten for various values of uri:
ws://localhost:6080
: 20 ms (custom python based WebSocket server)
ws://localhost:6090
: 3 ms (custom node.js + einaros/ws based WebSocket server)
ws://echo.websocket.org
: 130 ms
wss://echo.websocket.org
: 190 ms
So even using an encrypted connection to a public remote Websocket server is still less than one fifth of a second on average until the open event. The maximum time I saw was 250ms. For a local connection, the delay should really only be a few milliseconds.
My guess would be that you server setup is doing a bunch of processing before accepting the connection. Perhaps you are initializing a bunch of client data in the new connection handler?
Update:
Here is a simple einaros/ws based WebSocket server that gives 3 ms onopen response using the client test code above:
var WebSocketServer = require('ws').Server
, wss = new WebSocketServer({port: 6090});
wss.on('connection', function(ws) {
console.log("got connection");
});