我正在使用 "zerorpc": "^0.9.3" 在运行耗时的 python 代码时遇到了同样的问题。解决方法是需要修改zerorpc的库代码:node_modules -> zerorpc -> lib -> channel.js 将对应的方法改为
//Runs the heartbeat on this channel
Channel.prototype._runHeartbeat = function() {
var self = this;
return setInterval(function() {
if(util.curTime() > self._heartbeatExpirationTime) {
//If we haven't received a response in 2 * heartbeat rate, send an
//error
// self.emit("heartbeat-error", "Lost remote after " + (HEARTBEAT * 2) + "ms");
// self.close();
}
//Heartbeat on the channel
try {
var event = events.create(self._envelope, self._createHeader(), "_zpc_hb", [0]);
self._socket.send(event);
} catch(e) {
console.error("Error occurred while sending heartbeat:", e);
}
}, HEARTBEAT);
};
在来自 github 的最新代码中:https ://github.com/dotcloud/zerorpc-node
他们已经解决了这个问题。