New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot connect from node #372

Closed
robertpitt opened this Issue Jan 19, 2012 · 18 comments

Comments

Projects
None yet
8 participants
@robertpitt

robertpitt commented Jan 19, 2012

Seems like socket.io-client does not work in node@v0.6.7 running under node.

Versions

├─┬ node-inspector@0.1.10 
│ └── paperboy@0.0.3 
├─┬ socket.io@0.8.7 
│ ├── policyfile@0.0.4 
│ ├── redis@0.6.7 
│ └─┬ socket.io-client@0.8.7 
│   ├── uglify-js@1.0.6 
│   ├── websocket-client@1.0.0 
│   └── xmlhttprequest@1.2.2 
└─┬ socket.io-client@0.8.7 
  ├── uglify-js@1.0.6 
  ├── websocket-client@1.0.0 
  └── xmlhttprequest@1.2.2 

Running node@v0.6.7 it does not connect to any servers, test and production, the only events that are fired are connectiong and connect_failed.

Test Code

var SocketIOClient = require('socket.io-client');
var protocol    = 'ws';
var domain  = 'dev.domain.com';
var port    = 2006;
var options = {
    'max reconnection attempts' : 10,
    'reconnection delay'        : 2000,
    'transports'            : [
        'websocket'
    ]
}

var IOClient = SocketIOClient.connect(protocol + '://' + domain + ':' + port, options);

IOClient.on('connect', function(){
    console.log("Connected", arguments);
});

IOClient.on('connecting', function(){
    console.log("Connecting", arguments);
});

IOClient.on('connect_failed', function(){
    console.log("Connect Failed", arguments);
});

IOClient.on('message', function(){
    console.log("Message", arguments);
});

IOClient.on('reconnecting', function(){
    console.log("Reconnecting", arguments);
});

IOClient.on('reconnect_failed', function(){
    console.log("Reconnecting failed", arguments);
});

IOClient.on('close', function(){
    console.log("Server Closed", arguments);
});

IOClient.on('disconnect', function () {
    console.log("Disconnected", arguments);
});

Output

> node server.js
> Connecting { '0': 'websocket' }
> The "sys" module is now called "util". It should have a similar interface.
> Connect Failed {}

Theres about a 4-5 second delay between Connecting and Connection Failed

There's nothing wrong with the server sides it has thousands of clients connected via web-based websocket, seems like it might be a problem with the websocket-client

Can you please advise, thank you.

@jherdman

This comment has been minimized.

jherdman commented Jan 19, 2012

I had the same issue as well, but saw the client try to connect with the XHR transport after a while.

@robertpitt

This comment has been minimized.

robertpitt commented Jan 19, 2012

as you can see fro, the sample code I was using it does not allow XHR, only websocket permitted.

I have also traced it to the point where the available sockets are finalized and it stays at websocket, also it seems to close in the websocket-client module

@toots

This comment has been minimized.

toots commented Jan 22, 2012

I have this issue as well.

@robertpitt

This comment has been minimized.

robertpitt commented Jan 24, 2012

@liamks

This comment has been minimized.

liamks commented Jan 25, 2012

I also have this issue. @robertpitt how did you patch socket.io-client to get it to work?

@einaros

This comment has been minimized.

Contributor

einaros commented Jan 25, 2012

If you use master, rather than the latest npm version, this should be fixed. The websocket-client module has been replaced by the much more up to date ws.

@liamks

This comment has been minimized.

liamks commented Jan 25, 2012

@jherdman

This comment has been minimized.

jherdman commented Jan 25, 2012

Is master stable enough for a point release? It'd be nice to get this fix out in the wild.

On 2012-01-25, at 6:17 PM, Liam Kaufmanreply@reply.github.com wrote:

Thank you!!!

For others:

npm install https://github.com/LearnBoost/socket.io-client/zipball/master


Reply to this email directly or view it on GitHub:
#372 (comment)

@einaros

This comment has been minimized.

Contributor

einaros commented Jan 25, 2012

It should be. If @guille just stops slacking off at NodeSummit, a new version could be pushed.

@robertpitt

This comment has been minimized.

robertpitt commented Jan 26, 2012

For those that just want's to patch there current setup you can just grab the following file:

https://github.com/quangv/node-websocket-client/blob/b95c8e123bd1669f08cc1ae4c32c359127060926/lib/websocket.js

And then replace the following file:

/usr/local/lib/node_modules/socket.io-client/node_modules/websocket-client/lib

@ryanrolds

This comment has been minimized.

ryanrolds commented Feb 17, 2012

+1

@codecowboy

This comment has been minimized.

codecowboy commented Jan 7, 2014

I am also getting this problem using the OP's code and the current version of socket-io-client. Did ANYONE get this working?

Connecting { '0': 'websocket' }
Connected {}
Disconnected { '0': undefined }
Reconnecting { '0': 4000, '1': 1 }
Reconnecting { '0': 8000, '1': 2 }
Connecting { '0': 'websocket' }
Connected {}
Disconnected { '0': undefined }
Reconnecting { '0': 4000, '1': 1 }

@codecowboy

This comment has been minimized.

codecowboy commented Jan 7, 2014

@rauchg

This comment has been minimized.

Contributor

rauchg commented Jan 7, 2014

Try tarball?

@rauchg

This comment has been minimized.

Contributor

rauchg commented Jan 7, 2014

(instead of zipball in that URL)

@rauchg

This comment has been minimized.

Contributor

rauchg commented Jan 7, 2014

Oh by the way master is 1.0.0 so you might be looking for the latest 0.9.x tag instead

@codecowboy

This comment has been minimized.

codecowboy commented Jan 7, 2014

@guille Thanks! to be honest I'm not sure which version I need I just want something that works! I'm not sure if there is something wrong with the server I am trying to connect to, but I'm having the same problem as the original poster in this thread.

@codecowboy

This comment has been minimized.

codecowboy commented Jan 7, 2014

Tarball works (thanks) but installing 1.0 has the effect that my script now doesn't output anything, it just quits :(

@rauchg rauchg closed this Nov 25, 2014

lattmann pushed a commit to lattmann/socket.io-client that referenced this issue Jul 23, 2015

lattmann pushed a commit to lattmann/socket.io-client that referenced this issue Jul 23, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment