[zeromq-dev] How to disconnect a peer?

Pieter Hintjens ph at imatix.com
Thu Aug 28 19:18:11 CEST 2014


My usual strategy is to delete the peer after some timeout, and if the
peer returns, then treat it as a new peer. Secondly, treat an
out-of-order message as an error so that the client side can
re-initialize itself correctly. As example, see FILEMQ.

On Thu, Aug 28, 2014 at 5:33 PM, Goswin von Brederlow <goswin-v-b at web.de> wrote:
> Hi,
>
> I've been thinking of error scenarios for my PPPP protocol and one of
> the cases is a peer connecting to the server and becoming
> unresponsive. This could be accidental or a malicious peer.
>
> So what happens in that case?
>
> - zmq puts messages into the kernel buffers
> - zmq puts messages into the pipe (default 1000 messages)
> - No messages (real or heartbeat) come back from the client
>
> So one of 2 things happens:
>
> 1) the SNDHWM is reached and messages can't be send
> 2) the peer misses too many heartbeats
>
> Both cases flag the peer first as LATE and then as DEAD.
>
> I free up all the resources for a DEAD peer that I hold but what about
> resources zmq holds? There could be up to 1000 messages in the pipe
> and whatever the kernel buffer holds. Also there is a file descriptor
> and the peer identity and metadata are kept. That could add up to
> quite a bit.
>
> So here is my question:
>
> How do I disconnect a single peer from a ROUTER socket?
>
> The closest in the API seems to be zmq_disconnect(). But a) I didn't
> connect to the peer, the peer connected to me, and b) I don't have an
> endpoint, only a peer identity.
>
> And I can't tell the peer to disconnect since it is unresponsive.
>
>
> Is that something that should be there but is missing?
>
> MfG
>         Goswin
>
> PS: my code would also be pretty confused when a DEAD peer suddenly
> becomes alive again. And the tcp timeout is generally higher than my
> own timeout.
> _______________________________________________
> 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