[zeromq-dev] zmq_socket_monitor blocks port of REP/REQ TCP/IP in C

Björn Kuhlbrodt bjoern.kuhlbrodt at gpsolar.com
Tue Jan 21 09:15:58 CET 2014


Hi Peter

Hmm, too bad. As I said, socket_monitor is working fine (although not perfect maybe) in our application. It just does not close without messing up the context.
And if it's not good for watching the connection and messes up the context, how about a little warning in the doc: devolopers tool, instable, beta, ....? It took us _some_ time to isolate socket_monitor as the culprit.

Best regards
Björn



Dr. Björn Kuhlbrodt
Senior Software Developer
GP Inspect GmbH

Tel: +49 89 750778 4729 
Fax: +49 89 750778 4710 
Mail: bjoern.kuhlbrodt at gpsolar.com

GP Inspect GmbH | Hainbuchenring 9-11 | 82061 Neuried | Deutschland
Geschäftsführer | Christian Probst, Dr. Eric Rüland, Enis Ersü, Martin Heinrich
Amtsgericht München | HRB 173887

A company of ISRA VISION Group

------------------------------------------------------------------------------------------------------
This e-mail may contain material that is confidential, privileged and for the sole use of the intended recipient. Any review, reliance or
distribution by others or forwarding without express permission is strictly prohibited. If you are not the intended recipient, please
contact the sender and delete all copies. GP Inspect GmbH, ISRA VISION AG, its branches and subsidiaries herewith exclude
any liability for third-party information recognizably contained in this email or its attachments. Third-party information does not
necessarily reflect the opinion of GP Inspect GmbH or ISRA VISION AG.
------------------------------------------------------------------------------------------------------
WWW.GPSOLAR.COM

WWW.ISRAVISION.COM
------------------------------------------------------------------------------------------------------
-----Original Message-----
From: zeromq-dev-bounces at lists.zeromq.org [mailto:zeromq-dev-bounces at lists.zeromq.org] On Behalf Of Pieter Hintjens
Sent: Samstag, 18. Januar 2014 08:21
To: ZeroMQ development list
Subject: Re: [zeromq-dev] zmq_socket_monitor blocks port of REP/REQ TCP/IP in C

You should not be using monitoring for this, as there are various kinds of problem that won't show as disconnects. Instead, send heartbeat messages when there's no other traffic, and use the lack of traffic as a sign of trouble.

On Thu, Jan 16, 2014 at 4:59 PM, Björn Kuhlbrodt <bjoern.kuhlbrodt at gpsolar.com> wrote:
> Hello
>
>
>
> I' trying to use zmq_socket_monitor to get notice when my TCP/IP 
> socket is disconnected. I do not send much but the user would like to 
> know when something goes offline asap.
>
> All works fine up to the point where I stop the socket and (maybe a 
> while
> later) start a new one. Here's what I got:
>
>
>
> Main thread:
>
> m_pZContext = zmq_ctx_new();
>
> Start comm. threads
>
> Stop comm.  Threads
>
> zmq_ctx_term (m_pZContext); //_always crashes!
>
>
>
>
>
> Comm threads (n):
>
> void* pZReceiveSocket = zmq_socket(m_pZContext, ZMQ_REP);
>
> int result = zmq_bind(pZReceiveSocket, connection);
>
> int rc = zmq_socket_monitor(pZReceiveSocket, monitor.c_str(), 
> ZMQ_EVENT_ALL);
>
> Start monitor threads
>
> Do comm until stop signal
>
> Stop monitor threads
>
> int rc = zmq_unbind(pZReceiveSocket, connection);
>
> ASSERT(rc == 0);
>
> rc = zmq_close(pZReceiveSocket);
>
> ASSERT(rc == 0);
>
>
>
>
>
> Monitor threads (one per comm. Thread):
>
> rc = zmq_connect (m_MonitorSocket, monitor.c_str());
>
> handle events until stop signal
>
> rc = zmq_disconnect (m_MonitorSocket, monitor.c_str());
>
> ASSERT (rc == 0);
>
> int rc = zmq_close (m_MonitorSocket);
>
> ASSERT (rc == 0);
>
>
>
> All threads end gracefully, all sockets have a  low LINGER, but 
> zmq_ctx_term always crashes deep in libzmq.
>
>
>
> If I don't use zmq_ctx_term the next time I try to open I get address 
> in use.
>
>
>
> Only way out: don't use zmq_socket_monitor and all works fine. That's 
> too bad, tough as I'd really like to know asap when the connection is gone.
>
>
>
> Any Ideas? Need more Input?
>
>
>
> Best Regards
>
> Björn
>
>
>
>
>
>
>
>
>
>
>
>
>
> Dr. Björn Kuhlbrodt
>
> Senior Software Developer
>
> GP Inspect GmbH
>
>
>
> Tel: +49 89 750778 4729
>
> Fax: +49 89 750778 4710
>
> E-Mail: bjoern.kuhlbrodt at gpsolar.com
>
>
>
> GP Inspect GmbH | Hainbuchenring 9-11 | 82061 Neuried | Deutschland
>
> Geschäftsführer | Christian Probst, Dr. Eric Rüland, Enis Ersü, Martin 
> Heinrich
>
> Amtsgericht München | HRB 173887
>
>
>
> A company of ISRA VISION Group
>
>
>
> ----------------------------------------------------------------------
> --------------------------------
>
> This e-mail may contain material that is confidential, privileged and 
> for the sole use of the intended recipient. Any review, reliance or
>
> distribution by others or forwarding without express permission is 
> strictly prohibited. If you are not the intended recipient, please
>
> contact the sender and delete all copies. GP Inspect GmbH, ISRA VISION 
> AG, its branches and subsidiaries herewith exclude
>
> any liability for third-party information recognizably contained in 
> this email or its attachments. Third-party information does not
>
> necessarily reflect the opinion of GP Inspect GmbH or, ISRA VISION AG.
>
> ----------------------------------------------------------------------
> --------------------------------
>
> WWW.GPSOLAR.COM
>
>
>
> WWW.ISRAVISION.COM
>
> ----------------------------------------------------------------------
> --------------------------------
>
>
> _______________________________________________
> zeromq-dev mailing list
> zeromq-dev at lists.zeromq.org
> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
>
_______________________________________________
zeromq-dev mailing list
zeromq-dev at lists.zeromq.org
http://lists.zeromq.org/mailman/listinfo/zeromq-dev



More information about the zeromq-dev mailing list