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?

mpromonet
  • 11,326
  • 43
  • 62
  • 91
dvreed77
  • 2,217
  • 2
  • 27
  • 42
  • 1
    There is an answer in a similar question [How to configure ZeroRPC and timeouts](http://stackoverflow.com/questions/23203973/how-to-configure-zerorpc-and-timeouts) – mpromonet Feb 21 '15 at 14:31
  • please refer my answer for another post [python - How to configure ZeroRPC and timeouts - Stack Overflow](https://stackoverflow.com/questions/23203973/how-to-configure-zerorpc-and-timeouts) – crifan Jan 01 '20 at 09:38

2 Answers2

2

I'm using "zerorpc": "^0.9.3" I come across with the same issue when I was running a time-consuming python code. The way to solve the issue is that you need to modify the library code of zerorpc: node_modules -> zerorpc -> lib -> channel.js Change the cooresponding method to

//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);
};

In the latest code from github: https://github.com/dotcloud/zerorpc-node they have solved this issue.

spiralmoon
  • 3,084
  • 2
  • 25
  • 26
  • Is disabling heartbeat a recommended practice in this case ? I experience the same issue with Python processes longer that 10s. IMO, heartbeat shouldn't be frozen when a Python process is ongoing! – Kevin. Jul 24 '14 at 14:15
  • This is a bug in the old code, they should have let developer to set the heartbeat. – spiralmoon Jul 24 '14 at 18:27
0

If you can, use gevent.sleep to let zerorpc enough time to process waiting messages, including heartbeat.

Morti
  • 605
  • 5
  • 19