我正在尝试从ZeroRPC website运行Python服务器/node.js客户端HelloWorld示例。所有相关的库似乎都已正确安装,但在运行示例时,我得到了错误:
{ name: 'HeartbeatError',
message: 'Lost remote after 10000ms',
traceback: '' }有没有人看过这个?
发布于 2014-07-09 06:28:46
我正在使用"zerorpc":"^0.9.3“当我运行一个耗时的python代码时,我遇到了同样的问题。解决这个问题的方法是,您需要修改zerorpc的库代码: node_modules -> zerorpc -> lib -> channel.js将cooresponding方法更改为
//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的最新代码中,他们已经解决了这个问题。
发布于 2016-07-01 21:09:11
如果可以,使用gevent.sleep让zerorpc有足够的时间处理等待消息,包括心跳。
https://stackoverflow.com/questions/23722757
复制相似问题