[zeromq-dev] How to detect if a remote socket has closed

David.Briant at ubs.com David.Briant at ubs.com
Tue Aug 17 16:08:39 CEST 2010


I queue the socket creation and message sends onto the zmq thread (with
the IOLoop on it) (I have a UI thread as well as the thread from the
command line - 3 in all).

I call the bind and the setsockopt from the command line thread - should
I queue these to the zmq thread?


I think I need three sockets to run a peer-to-peer connection:
	one to initiate the connection (REQ/REP)
	one to inform that I've restarted (PUB/SUB) - could also run a
service to caller heartbeat over this
	one to carry the asynchronous application messages (PAIR)


So one situation I haven't figured yet is failover of a publisher. Say I
have a data feed that goes down and I want all its clients to go to the
alternate one. The client needs to realise that it hasn't had a
heartbeat and then search for another one.

I don't really want a routing mechanism outside of the application (for
sake of maintenance). I'd prefer to be able to connect and send messages
point-to-point / peer-to-peer, detect failure and do resource discovery
from the application.



-----Original Message-----
From: zeromq-dev-bounces at lists.zeromq.org
[mailto:zeromq-dev-bounces at lists.zeromq.org] On Behalf Of Pieter
Hintjens
Sent: Tue 17-Aug-2010 14:35
To: 0MQ development list
Subject: Re: [zeromq-dev] How to detect if a remote socket has closed

On Tue, Aug 17, 2010 at 3:15 PM,  <David.Briant at ubs.com> wrote:

> LOL. things never "just work" !!!
>
> I'm finding that I'm hanging on socket creation a lot. Is that usual?

Nope, that assertion means something is broken, perhaps the build.
I'm asking Martin S. over on the IRC channel...

> I'm running the zmq loop in a different thread and queuing the
creation to that thread and waiting until creation is done (do while
notCreated(): sleep 0.01 in python). I'm using the call back api in
IOLoop to do the queuing.

Are you accessing the same 0MQ socket from two threads?

> My recovery strategy is:
>
> Once I know there's a failure search for a remote connection that
provides the same service, if I can't find one report back to the UI.
this is more general than having a bunch of servers because a) the user
might need to do the restart (in this case the crashed excel), b) the
topology might not be known before hand (the user might be writing a
"server" in excel that only needs to be around for a few minutes to get
the particular job done).

Sounds like you need (a) heartbeats and (b) a routing mechanism that
favors local services but will search for remote ones if necessary.
You can do both these fairly simply on top of 0MQ IMO.  However if you
want to design this properly you're going to have to learn more about
how 0MQ works, how the different socket types work.

-
Pieter Hintjens
iMatix - www.imatix.com
_______________________________________________
zeromq-dev mailing list
zeromq-dev at lists.zeromq.org
http://lists.zeromq.org/mailman/listinfo/zeromq-dev
Visit our website at http://www.ubs.com

This message contains confidential information and is intended only 
for the individual named.  If you are not the named addressee you 
should not disseminate, distribute or copy this e-mail.  Please 
notify the sender immediately by e-mail if you have received this 
e-mail by mistake and delete this e-mail from your system.
	
E-mails are not encrypted and cannot be guaranteed to be secure or 
error-free as information could be intercepted, corrupted, lost, 
destroyed, arrive late or incomplete, or contain viruses.  The sender 
therefore does not accept liability for any errors or omissions in the 
contents of this message which arise as a result of e-mail transmission.  
If verification is required please request a hard-copy version.  This 
message is provided for informational purposes and should not be 
construed as a solicitation or offer to buy or sell any securities 
or related financial instruments.

UBS Limited is a company registered in England & Wales under company
number 2035362, whose registered office is at 1 Finsbury Avenue,
London, EC2M 2PP, United Kingdom.

UBS AG (London Branch) is registered as a branch of a foreign company
under number BR004507, whose registered office is at
1 Finsbury Avenue, London, EC2M 2PP, United Kingdom.

UBS Clearing and Execution Services Limited is a company registered
in England & Wales under company number 03123037, whose registered
office is at 1 Finsbury Avenue, London, EC2M 2PP, United Kingdom.
 
UBS reserves the right to retain all messages. Messages are protected
and accessed only in legally justified cases.



More information about the zeromq-dev mailing list