簡體   English   中英

在node.js上使用Socket.io“錯誤:寫EPIPE”

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

我手動應用了此補丁,現在一切正常。 在上游等待修復此 https://github.com/LearnBoost/socket.io-client/pull/361/files


我只是在嘗試遵循給出的示例並試圖使它起作用。

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:

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);
});

然后我在另一個終端上運行節點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

此時我停止了Mockclient.js

- lost a client
   debug - discarding transport

“ node Mockclient.js”的唯一輸出是

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

是什么導致套接字異常? 我可能錯過了一些非常明顯的東西。 此外,有人可以嘗試我的代碼,以查看他們的機器上的錯誤是否也是如此? socket.on里面的代碼('connect'...也沒有觸發。我不知道為什么。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM