简体   繁体   English

在node.js上使用Socket.io“错误:写EPIPE”

[英]“Error: write EPIPE” with Socket.io on node.js

I manually applied this patch and everything works now. 我手动应用了此补丁,现在一切正常。 Waiting on upstream to fix this https://github.com/LearnBoost/socket.io-client/pull/361/files 在上游等待修复此 https://github.com/LearnBoost/socket.io-client/pull/361/files


I'm just trying to follow the examples given and trying to get this to work. 我只是在尝试遵循给出的示例并试图使它起作用。

Mockserver.js: Mockserver.js:

var io = require('socket.io').listen(8000);

io.sockets.on('connection', function(client) {
    console.log('+ new client');
    client.on('disconnect', function() {
        console.log('- lost a client');
    });
});

Mockclient.js: Mockclient.js:

var io = require('socket.io-client');
var socket = new io.connect('localhost', { port: 8000 });

socket.on('connect', function() {
    console.log('connected');
});

socket.on('message', function(data) {
    console.log(data);
});

I then run these pair with node Mockserver.js and node Mockclient.js on another terminal 然后我在另一个终端上运行节点Mockserver.js和节点Mockclient.js

   info  - socket.io started
   debug - client authorized
   info  - handshake authorized 14797776461130411158
   debug - setting request GET /socket.io/1/websocket/14797776461130411158
   debug - set heartbeat interval for client 14797776461130411158
   debug - client authorized for 
   debug - websocket writing 1::
+ new client
   debug - set close timeout for client 14797776461130411158
   ***************************** error occurs here ****************
   info  - socket error Error: write EPIPE
   at errnoException (net.js:632:11)
   at Object.afterWrite [as oncomplete] (net.js:470:18)
   ****************************************************************
   debug - setting request GET /socket.io/1/xhr-polling/14797776461130411158?t=1325912082073
   debug - setting poll timeout
   debug - discarding transport
   debug - cleared close timeout for client 14797776461130411158
   debug - cleared heartbeat interval for client 14797776461130411158
   debug - clearing poll timeout
   info  - transport end
   debug- set close timeout for client 14797776461130411158
   debug - cleared close timeout for client 14797776461130411158

at this point I stopped Mockclient.js 此时我停止了Mockclient.js

- lost a client
   debug - discarding transport

The only output for "node Mockclient.js" is “ node Mockclient.js”的唯一输出是

The "sys" module is now called "util". It should have a similar interface.

What's causing the socket exception? 是什么导致套接字异常? I'm probably missing something pretty obvious. 我可能错过了一些非常明显的东西。 Also, can somebody else try my code to see if the errors on their machine as well? 此外,有人可以尝试我的代码,以查看他们的机器上的错误是否也是如此? The code inside socket.on('connect'... isn't triggering either. I don't exactly know why. socket.on里面的代码('connect'...也没有触发。我不知道为什么。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM