3

I have a problem with socket.io.

This error: warn - client not handshaken client should reconnect

In the console I have a list of errors:

debug - setting poll timeout
   debug - clearing poll timeout
   debug - xhr-polling writing 7:::1+0
   debug - set close timeout for client 17348980511779302969
   warn  - client not handshaken client should reconnect
   info  - transport end

I have this simple application:

require.paths.unshift(__dirname + '/../../lib/');

var express = require('express');
var app = express.createServer();
var io = require('socket.io').listen(app);
var stylus = require('stylus');
var mysql = require('mysql');

app.use(express.bodyParser());
app.use(express.cookieParser());

app.use(stylus.middleware({ src: __dirname + '/public', compile: compile }))
app.use(express.static(__dirname + '/public'));
app.set('views', __dirname);

app.set("view options", { layout: false });

app.register('.html', {
    compile: function (str, options) {
        return function (locals) {
            return str;
        };
    }
});

function compile(str, path) {
    return stylus(str)
      .set('filename', path)
      .use(nib());
};

app.get('/', function (req, res) {
res.render('index.html', { layout: false });
});


io.configure(function () {
    io.set('transports', ['websocket','flashsocket','xhr-polling']);
    io.set('polling duration', '10');
});

io.sockets.on('connection', function (socket) {

    console.log("Connect with ID: " + socket.id);   

    socket.emit("sendid", {id: socket.id});

    socket.on('disconnect', function () {
        console.log("Disconnect with ID: " + socket.id);
    });

});

app.listen(3000);

CLIENT CODE:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
    <title>Socket.IO - test</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <script src="/socket.io/socket.io.js" type="text/javascript"></script>
    <script type="text/javascript">

        var WEB_SOCKET_SWF_LOCATION = './WebSocketMain.swf';

    var socket = io.connect(null, {
            'connect timeout': 500,
            'reconnect': true,
            'reconnection delay': 500,
            'reopen delay': 500,
            'max reconnection attempts': 10
        });

    socket.on('sendid', function (data) {
            alert("Your socket ID is: " + data.id);
        });

    </script>
</head>
<body>
Test socket.io.
</body>
</html>
Jenan
  • 3,408
  • 13
  • 62
  • 105

1 Answers1

4

i have downloaded the latest version of the socket.io and socket.io-client.

I set the URL and port for connection to socket.io - on the client side.

 var socket = io.connect('http://domain.com:port', {
            'connect timeout': 500,
            'reconnect': true,
            'reconnection delay': 500,
            'reopen delay': 500,
            'max reconnection attempts': 10
        });
Jenan
  • 3,408
  • 13
  • 62
  • 105
  • 3
    i've socket.io 0.9.9 and this don't stop the failure. When I restart the app I get a lot of this errors (10k users) – nax Aug 06 '12 at 12:03
  • @jenan : even after updating code as u suggested, it still gives same error. Any workaround for that? – Pritam Apr 11 '15 at 12:56