简体   繁体   English

ZMQ 丢失订阅连接

[英]ZMQ Losing subscribe connection

Am using ZMQ publish and multiple subscribe.Am Publishing every 10 sec.At first all subscribe works fine.我正在使用 ZMQ 发布和多个订阅。我每 10 秒发布一次。起初所有订阅都可以正常工作。 But later the connection is broken.但后来连接断开了。

How to alive connection without broken.Am using zmq npm 2.15.0 version.如何在不中断的情况下保持连接。我正在使用 zmq npm 2.15.0 版本。

ZeroMQ L3-level connection maintenance is hidden "inside" or "behind" the published API and runs behind the scene. ZeroMQ L3 级连接维护隐藏在已发布的 API 的“内部”或“背后”,并在幕后运行。

Whenever some intermittent errors appear, the both sides' Context() -instances of the "so-far-connected" peers pay (internally) due attention and try to re-establish their Line-of-Sight ( LoS ), as needed for some transport.每当出现一些间歇性错误时,双方的Context() -“迄今为止连接”对等点的实例都会(内部)给予应有的关注,并根据需要尝试重新建立它们的视线 (LoS)一些交通工具。

Best re-read the documented API details for {.setsockopt() |.getsockopt() } -methods, where many parameters have effects on how the re-establishment(s) of the LoS actually take place "inside" the internal, service-side connection-maintenance.最好重新阅读记录在案的 API 详细信息以了解{.setsockopt() |.getsockopt() }方法,其中许多参数会影响 LoS 的重建实际上如何发生在内部服务“内部” - 侧连接维护。

May get inspired by experimenting with ZMQ_HEARTBEAT_IVL != 0 and configuring ZMQ_HEARTBEAT_TIMEOUT and ZMQ_HEARTBEAT_TTL values.可以通过尝试ZMQ_HEARTBEAT_IVL != 0并配置ZMQ_HEARTBEAT_TIMEOUTZMQ_HEARTBEAT_TTL值来获得启发。

Thanks for answer its fixed now with this code感谢您现在使用此代码修复它

const zmq = require("zmq");
const sock = zmq.socket("sub");
sock.setsockopt(zmq.ZMQ_TCP_KEEPALIVE, 1);
sock.setsockopt(zmq.ZMQ_TCP_KEEPALIVE_IDLE, 300);
sock.setsockopt(zmq.ZMQ_TCP_KEEPALIVE_CNT, 10)
sock.setsockopt(zmq.ZMQ_TCP_KEEPALIVE_INTVL, 300);
sock.connect("tcp://mdata-pub-01:3000");

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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