简体   繁体   中英

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?

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 ....

for latest js zerorpc version v0.9.8 :

# npm list zerorpc
xxx/electron-python-example
└── zerorpc@0.9.8 

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 <bombela+zerorpc@gmail.com>.
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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM