Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Node.js and socket.io - client not handshaken client should reconnect

Node.js and socket.io - client not handshaken client should reconnect

Problem

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:




    Socket.IO - test
Test socket.io.


Problem courtesy of: Jenan

Solution

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
        });
Solution courtesy of: Jenan

Discussion

View additional discussion.



This post first appeared on Node.js Recipes, please read the originial post: here

Share the post

Node.js and socket.io - client not handshaken client should reconnect

×

Subscribe to Node.js Recipes

Get updates delivered right to your inbox!

Thank you for your subscription

×