ZMQ发布 - 订阅程序故障时丢失网络连接 [英] ZMQ Pub-Sub Program Failure When Losing Network Connectivity

查看:1990
本文介绍了ZMQ发布 - 订阅程序故障时丢失网络连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个中等规模的网络上的简单的发布 - 订阅设置,使用ZMQ 2.1。虽然有些用户正在使用C#绑定,别人都在用Python绑定,而我遇到的问题是不是一样的。

I have a simple pub-sub setup on a mid-sized network, using ZMQ 2.1. Although some subscribers are using C# bindings, others are using Python bindings, and the issue I'm having is the same for either.

如果我拉网线从机中运行的用户,我得到一个未开捕错误立即终止该订户。

If I pull the network cable from a machine running a subscriber, I get an un-catchable error that immediately terminates that subscriber.

下面是用Python(而不是实际的生产代码,但足以重现该问题)用户的一个非常简单的例子:

Here's a very simple example of a subscriber in Python (not actual production code, but enough to reproduce the problem):

import zmq

def main(server_address, port):

    context = zmq.Context()
    sub_socket = context.socket(zmq.SUB)
    sub_socket.connect("tcp://" + server_address + ":" + str(port))
    sub_socket.setsockopt(zmq.SUBSCRIBE, "KITH1S2")

    while True:

        msg = sub_socket.recv()      
        print msg  

if __name__ == "__main__": main("company-intranet", 4000)

在C#程序则只是静静地终止。在Python我至少可以得到这样的:

In C# the program simply terminates silently. In Python I at least get this:

断言失败:RC == 0(.... \src\zmq_connector.cpp :48)

Assertion failed: rc == 0 (....\src\zmq_connector.cpp:48)

此应用程序已请求运行时终止它以一种不寻常的方式。
请与应用程序的支持团队以获取更多信息。

This application has requested the Runtime to terminate it in an unusual way. Please contact the application's support team for more information.

我试过非阻塞版本,以及轮询版本,但在这两种情况下,这立即终止问题仍然存在。有什么明显我的的做,但我不? (也就是说,明显给别人:))

I've tried non-blocking versions, and poller versions, but in either case this instant termination problem persists. Is there something obvious I should be doing but I'm not? (That is, obvious to someone else :) ).

编辑:

发现: https://zeromq.jira.com/browse/LIBZMQ-207

好像是/是一个已知的问题。

Seems as though it is/was a known issue.

链接进一步指向Github上,其中一个更改日志2.1.10有这样一个字条:

That link further links to Github, where a change log for 2.1.10 has this note:


  • 修正了207,在zmq_connecter.cpp断言失败:48,当
    无效zmq_connect()用于字符串或主机名不能
    解决。该zmq_connect()调用现在返回-1这两种这些情况。

虽然的连接()的确实抛出了一个Python无效参数异常(不是C#显然?)的的recv()的仍然失败。如果用户机器突然失去网络后,该用户将简单地停止运行。

Although connect() does indeed throw an Invalid Argument exception in Python (not C# apparently?), recv() still fails. If the subscriber machine suddenly loses the network, that subscriber will simply stop functioning.

所以 - 我会使用IP地址,而不是指定的地址,看看这是否会绕开问题去尝试。 。不是很理想,但比斯塔碰撞更好

So - I'm going to try using IP addresses instead of named addresses to see if this will bypass the issue. Not ideal, but better than insta-crash.

推荐答案

原题:有什么明显的我应该做的,但我不?

没有。

对于现在的解决方法是使用IP寻址。这不为后ZMQ 2.1.x.网络断开导致程序失效

The workaround for now is to use IP addressing. This does not cause program failure upon network disconnect for ZMQ 2.1.x.

这篇关于ZMQ发布 - 订阅程序故障时丢失网络连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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