Issues connecting a node-driven socket.io-client to a node socket.io server

911 views
Skip to first unread message

holden

unread,
Dec 20, 2011, 12:29:42 PM12/20/11
to Socket.IO
I am trying to glue my backend node.js socket.io processes for my web
app together using socket.io-client in the node environment.

Here is the code that doesn't work:

Server Side ("master server"):
<code>
var io = require("socket.io").listen(3333);

io.sockets.on('connection',function(socket){
console.log("got a connection");
socket.on('disconnect',function(){
console.log("got a disconnect");
});
});
</code>

Client Side ("slave server"):
<code>
var io = require("socket.io-client")

var socket;
console.log("Connecting to 127.0.0.1:3333");
socket = io.connect("http://127.0.0.1:3333");
socket.on('connect', function(){
console.log("Connected to 127.0.0.1:3333");

});
socket.on('message', function(evt){
console.log("Recieved a message: " + evt);
});
socket.on('disconnect', function(){
console.log("Disconnected from 127.0.0.1:3333");
});
</code>


Console of Master Server:
<code>
debug - client authorized
info - handshake authorized 1639887829241819794
debug - setting request GET /socket.io/1/websocket/
1639887829241819794
debug - set heartbeat interval for client 1639887829241819794
debug - client authorized for
got a connection
debug - websocket writing 1::
debug - set close timeout for client 1639887829241819794
info - socket error Error: write ECONNABORTED
at errnoException (net.js:614:11)
at Socket._write (net.js:435:18)
at Socket.write (net.js:424:15)
at WebSocket.write (c:\Users\Holden\Desktop\server\node_modules
\socket.io\lib\transports\websocket\default.js:192:23)
at WebSocket.flush (c:\Users\Holden\Desktop\server\node_modules
\socket.io\lib\transports\websocket\default.js:213:10)
at Socket.<anonymous> (c:\Users\Holden\Desktop\server\node_modules
\socket.io\lib\transports\websocket\default.js:159:14)
at Socket.emit (events.js:67:17)
at TCP.onread (net.js:322:31)
debug - fired close timeout for client 1639887829241819794
info - transport end
got a disconnect
debug - discarding transport
</code>


On the node-driven client side ("slave server") all that prints is
<code>
Connecting to 127.0.0.1:3333
The "sys" module is now called "util". It should have a similar
interface.
</code>

If I add events to the slave server to look for the "connecting" event
I see that it fails the websocket connection, then moves on to xhr-
polling. After failing xhr-polling it gets stuck in an infinite loop
described here:
https://github.com/LearnBoost/socket.io/issues/438

Does anyone have any suggestions as to what I may be doing wrong or if
this is a socket.io/socket.io-client issue, how to fix it?

Thanks,

holden

unread,
Dec 20, 2011, 2:13:42 PM12/20/11
to Socket.IO
<faced> `3rdEden I found a post by you about running socket.io-client
on node here: https://github.com/LearnBoost/socket.io-client/pull/274<faced>
Is this functionality still supported in 0.8.7?<faced> I have been
trying to get it to work but have so far been unsuccessfull. Google
groups here: http://groups.google.com/group/socket_io/browse_thread/thread/e12b27f2b16ec8eb#
<`3rdEden> faced it should still be supported
<`3rdEden> but idk about node 0.6
<`3rdEden> i'm currently adding a browser based interface to einaros's
WS module
<`3rdEden> so we can use it in the socket.io client
<`3rdEden> because that is one of the point it would probably break on
<faced> hmm interesting.. what version of node would you reccomend?
<faced> `3rdEden: I'm on windows so I couldn't go back to 0.4.12,
however.. I cycled through 0.5 versions until I found one which works
(0.5.3).. It would be great to get this functionality working in node
0.6 but this will do for now. Thank you again for the hint
<faced> Just went through all the 0.5 versions.. the node socket.io-
client websocket functionality was broken in between node version
0.5.3 and 0.5.4.. I will post this to the google groups for future
reference

Bill Enright

unread,
Dec 31, 2011, 7:10:41 PM12/31/11
to sock...@googlegroups.com
I wrestled with this for a week or two 0n 0.6.n...then gave up and
went back to node 0.4.n
It looked to me like the client socket was disconnecting (it looked
like the server socket side of things was OK), but I did not dig
deeper.
I only wanted to use a client socket on the server in order to do unit testing.

b

--
twitter: billyenright

Arnout Kazemier

unread,
Jan 1, 2012, 7:07:08 AM1/1/12
to sock...@googlegroups.com
I made a pull request for changing the WebSocket client here: https://github.com/LearnBoost/socket.io-client/pull/361
Tested it on on node 0.4 and node 0.6 and worked fine.
Reply all
Reply to author
Forward
0 new messages