1

Im trying to run the Python server/node.js client HelloWorld example from the ZeroRPC website. All the revelant libraries seemed to have been installed correctly, but when running the example I get the error:

{ name: 'HeartbeatError',
  message: 'Lost remote after 10000ms',
  traceback: '' }

Has anyone seen this?

4

2 回答 2

2

我正在使用 "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 他们已经解决了这个问题。

于 2014-07-08T22:28:45.523 回答
0

如果可以,请使用 gevent.sleep 让 zerorpc 有足够的时间来处理等待消息,包括心跳。

于 2016-07-01T13:09:10.940 回答