[zeromq-dev] Ping Pong Heartbeats & Quick Server Restart Issue

Russell Della Rosa rdellar2000-zeromq at yahoo.com
Mon Mar 23 15:26:05 CET 2015

Thanks, I really like this idea.  

I was trying to keep my server stateless, but so far haven't come up with a way to do that.  

Maybe there isn't a stateless way or socket pattern that will handle this case.

From: Doron Somech <somdoron at gmail.com>
To: Russell Della Rosa <rdellar2000-zeromq at yahoo.com>; ZeroMQ development list <zeromq-dev at lists.zeromq.org> 
Sent: Saturday, March 21, 2015 2:44 PM
Subject: Re: [zeromq-dev] Ping Pong Heartbeats & Quick Server Restart Issue

Make the protocol between the client and server stateful and have some kind of handshake between client and server.

So when the server dies and then restart quickly, client sending a ping message will be replied with an error as the server doesn't know the client. The client then will re-initiate the handshake and will expire immediately any pending requests which you can know resend. To summarize:

1. Have handshake / login process between client and server
2. Server has a hash table of all clients (routing id to client) - which it added client to it as part of the handshake process
3. Client sends a ping every X seconds
4. Server receives a ping and reply with pong if the client is known or error if client is unknown
5. Client that receives an error from a ping re-initiate the handshake/login process
6. Client immediately expire pending requests when error is received / or resending all pending requests after handshake is completed

On Fri, Mar 20, 2015 at 8:53 PM, Russell Della Rosa <rdellar2000-zeromq at yahoo.com> wrote:

>I'm curious if anyone has solved this quick server restart problem in a clean way with socket patterns?  Or if you have other suggestions?  
>Or if you have example code of ping/pong handling this case I'd love to see it.
> -- Russell
>Related threads:
>Disconnects / Retry Logic - http://lists.zeromq.org/pipermail/zeromq-dev/2012-January/015024.html
>Using a router with an identity issue - http://lists.zeromq.org/pipermail/zeromq-dev/2014-February/025206.html
>zeromq-dev mailing list
>zeromq-dev at lists.zeromq.org

More information about the zeromq-dev mailing list