节点js 0.10.7:集群支持udp dgram?

时间:2013-05-23 21:29:48

标签: node.js udp cluster-computing

我正在尝试按照提到的https://github.com/joyent/node/issues/2194

运行以下节点js应用程序
var util = require("util"),
  dgram = require("dgram"),
  cluster = require('cluster');

var udp = dgram.createSocket("udp4");
var port = 1190;

if (cluster.isMaster) {
  for (i = 0; i < 2; i++) {
    cluster.fork();
  }
} else {
  util.log("starting udp server on port " + port);
  udp.on("error", function (error) {
    util.log("failed to bind to UDP port - " + error)
  });
  udp.bind(port);
}

应用程序会立即退出并输出以下内容:

23 May 23:22:13 - starting udp server on port 1190
23 May 23:22:13 - starting udp server on port 1190

events.js:72
        throw er; // Unhandled 'error' event
              ^
Error: write ENOTSUP - cannot write to IPC channel.
    at errnoException (child_process.js:980:11)
    at ChildProcess.target.send (child_process.js:455:16)
    at Worker.send (cluster.js:401:21)
    at sendInternalMessage (cluster.js:394:10)
    at handleResponse (cluster.js:177:5)
    at respond (cluster.js:192:5)
    at Object.messageHandler.queryServer (cluster.js:242:5)
    at handleMessage (cluster.js:197:32)
    at ChildProcess.EventEmitter.emit (events.js:117:20)
    at handleMessage (child_process.js:318:10)

有谁知道发生了什么事?没有集群运行时,一切都很好。 看来群集不支持udp?

一些规格:

Window 7 x64
node js 0.10.7

1 个答案:

答案 0 :(得分:1)

它表示在v0.11.14中添加了对UDP群集的支持所提供的链接。您可能只需要更新node.js的版本