【问题标题】:"Error: write EPIPE" with Socket.io on node.js“错误:在 node.js 上使用 Socket.io 编写 EPIPE”
【发布时间】:2012-02-04 18:05:45
【问题描述】:

我手动应用了这个补丁,现在一切正常。等待上游解决此问题 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'... 中的代码也没有触发。我不知道为什么。

【问题讨论】:

    标签: javascript node.js socket.io serverside-javascript


    【解决方案1】:

    【讨论】:

    • 打补丁后报错:module.js:332 throw new Error("Cannot find module '" + request + "'"); ^ 错误:找不到模块 'ws' 有什么想法吗?
    • @MartinKapfhammer 你可能想做一个npm install -g ws
    猜你喜欢
    • 2014-12-26
    • 2014-04-15
    • 1970-01-01
    • 2020-12-04
    • 2015-08-17
    • 2019-01-21
    • 2016-04-25
    • 1970-01-01
    • 2020-10-06
    相关资源
    最近更新 更多