我正在尝试使用ZeroRPC python服务器和node.js客户端进行一些简单的负载测试。我注意到,如果请求花费的时间超过10秒,我就得不到任何数据。我尝试在python代码中配置无心跳:
s = zerorpc.Server(Test(), heartbeat=None)以及尝试配置node.js客户端:
new zerorpc.Client({ timeout: 60, heartbeatInterval: 60000 }),但仍然可以看到相同的行为。
如何获得超过10秒才返回结果的请求?
发布于 2014-11-08 06:30:15
zerorpc-node的最新版本(0.9.3)使用了harcoded的心跳超时。
正如您在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;
};但是,最新的主发行版按照您尝试在客户端构造器中指定的方式实现了hearbeatInterval选项。
然后您的代码就可以使用下面的命令安装最新的主文件了
npm install git+https://github.com/dotcloud/zerorpc-node.git或者等待新版本的发布...
发布于 2020-01-01 17:36:58
有关最新的js zerorpc版本v0.9.8
# npm list zerorpc
xxx/electron-python-example
└── zerorpc@0.9.8 和最新的python zerorpc版本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: 它已经为你提供了heartbeatInterval。
所以我在这里使用代码electron-python-example/renderer.js
const constLargeEnoughHeartbeat = 60 * 60 * 24 * 30 * 12 // 1 Year
clientOptions = {
"heartbeatInterval": constLargeEnoughHeartbeat,
}
let client = new zerorpc.Client(clientOptions)可以实现你所期望的:大到足以1年心跳->这么长10秒,js和python还在运行,没有更多错误。
invoke startSaver: error=Error: Lost remote after 10000ms
zerorpc.exceptions.LostRemote: Lost remote after 10s heartbeat:
https://stackoverflow.com/questions/23203973
复制相似问题