user2395365
user2395365

Reputation: 2149

How to configure ZeroRPC and timeouts

I'm trying to do some simple load-testing with a ZeroRPC python server and node.js client. What I notice is that if the request takes longer than 10 seconds, I get no data back. I tried to configure no heartbeat in the python code:

s = zerorpc.Server(Test(), heartbeat=None)

as well as trying to configure the node.js client:

new zerorpc.Client({ timeout: 60, heartbeatInterval: 60000 }),

but still see the same behavior.

How can I get requests taking longer than 10 seconds to return results?

Upvotes: 5

Views: 3444

Answers (2)

crifan
crifan

Reputation: 14318

for latest js zerorpc version v0.9.8:

# npm list zerorpc
xxx/electron-python-example
└── [email protected] 

and latest python zerorpc version v0.6.3

# pip show zerorpc             
Name: zerorpc
Version: 0.6.3
Summary: zerorpc is a flexible RPC based on zeromq.
Home-page: https://github.com/0rpc/zerorpc-python
Author: François-Xavier Bourlet <[email protected]>.
Author-email: UNKNOWN
License: MIT
Location: xxx/venv/lib/python3.8/site-packages
Requires: msgpack, future, pyzmq, gevent
Required-by: 

which provide you already said the heartbeatInterval.

so my here using code electron-python-example/renderer.js:

const constLargeEnoughHeartbeat = 60 * 60 * 24 * 30 * 12 // 1 Year
clientOptions = {
  "heartbeatInterval": constLargeEnoughHeartbeat,
}
let client = new zerorpc.Client(clientOptions)

can implement you expected: large enough to 1 year heartbeat -> so longer than 10s, js and python still running, no more error

  • js: invoke startSaver: error=Error: Lost remote after 10000ms
  • python: zerorpc.exceptions.LostRemote: Lost remote after 10s heartbeat

Upvotes: 0

mpromonet
mpromonet

Reputation: 11942

The last available release of zerorpc-node (0.9.3) use an harcoded HEARBEAT timeout.

As you can see in https://github.com/dotcloud/zerorpc-node/blob/0.9.3/lib/channel.js :

//Heartbeat rate in milliseconds
var HEARTBEAT = 5000;
...
//Resets the heartbeat expiration time
Channel.prototype._resetHeartbeat = function() {
    this._heartbeatExpirationTime = util.curTime() + HEARTBEAT * 2;
};

However the latest master release implement the hearbeatInterval option as you try to specify in the client contructor.

Then your code works installing the lastest master with the command

npm install git+https://github.com/dotcloud/zerorpc-node.git

Or wait for a new release ....

Upvotes: 0

Related Questions