如何配置 ZeroRPC 和超时 [英] How to configure ZeroRPC and timeouts

查看:44
本文介绍了如何配置 ZeroRPC 和超时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 ZeroRPC python 服务器和 node.js 客户端进行一些简单的负载测试.我注意到的是,如果请求花费的时间超过 10 秒,我将不会收到任何数据.我尝试在python代码中不配置心跳:

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)

以及尝试配置 node.js 客户端:

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

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

但仍然看到相同的行为.

but still see the same behavior.

如何让请求的时间超过 10 秒才能返回结果?

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

推荐答案

最新js zerorpc 版本 v0.9.8:

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

和最新的 python zerorpc 版本 v0.6.3

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: 

提供您已经说过的heartbeatInterval.

所以我在这里使用代码 electron-python-example/renderer.js:

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)

可以实现你的预期:足够大到 1 年的心跳 -> 超过 10 秒,js 和 python 仍在运行,没有更多错误

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:10s 心跳后丢失遥控器

这篇关于如何配置 ZeroRPC 和超时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆