开发者

Node.js connection error, missing property?

EDIT

Solution:

Visit your IP in the browser after you "node server.js" to kick-start the connections. Dunno why it works, but it does for me.

How it came to be

Mkay.. after making a rebuild of the slice (hosted at slicehost if that matters) and reinstalling node and websocket-server I still had the same issue. I checked if a normal request worked (entering the IP in the browser) which it did. It also seemed to kick-start the socket connections, so I could now connect through those too.


I'm trying to connect to a socket server using node.js and the websocket-server module.

Server side looks like this:

   var server = ws.createServer();
   server.listen(80);

   server.addListener("request", function(req, res) {

   res.writeHead(200, {
    "Content-Type": "text/plain"
   });
   res.write("Hey! This is totally not the site you planned to visit.");
   res.end();
   });

  server.addListener("connection", function(conn) {

   conn.addListener("readyStateChange", function(readyState) {

   });
   conn.addListener("open", function() {

   });
   conn.addListener("close", function() {

   });
   conn.addListener("message", function(message) {
    server.broadcast(conn._id + ": "+message);
   });
 });

Standard procedure. When trying to connect from the client like this...

   if ( window["WebSocket"] ) {

            connection = new WebSocket("ws://[my IP]:80/");
            connection.onopen = function( event ) {
                console.log("connection open");
            }

            connection.onclose = function( event ) {
                console.log("connection closed");
            }

            connection.onerror= function( event ) {
                console.log("connection error");
            }

            connection.onmessage = function( event ) {
                console.log(event.data);
            };
        }

... I get the following error:

_linklist.js:65

item._idleNext = list._idleNext;

TypeError: Cannot read property '_idleNext' of undefined at Object.append (_linklist.js:65:24) at Object.active (timers.js:136:9) at Socket._writeOut (net.js:461:10)

at Socket.write (net.js:378:17)
at Object.draft76 ([my dir]/npm/node_modules/websocket-server/lib/ws/connection.js:401:28)
at new Connection ([my dir]npm/node_modules/websocket-server/lib/ws/connection.js:165:22)
at Server.<anonymous> ([my dir]npm/node_modules/websocket-server/lib/ws/server.js:72:7)
at Server.emit (events.js:81:20)
at Socket.<anonymous> (http.js:1034:14)
at Socket._onReadable (net.js:684:27)

It did run for a while (which is weird I guess), and then this message started appearing whenever I tried to conn开发者_Go百科ect. I haven't changed anything in the node.js or websocket-server code. A penny to whomever can tell me why this happens!


Visit your IP in the browser after you "node server.js" to kick-start the connections. Dunno why it works, but it does for me.

Also, make sure you have a stable version of Node. I had an unstable one when the issue appeared.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜