[zeromq-dev] Limit number of connections on socket

Pieter Hintjens ph at imatix.com
Tue Mar 17 17:15:50 CET 2015


The socket monitor cannot close connections.

You can do part of this using a ZAP handler and enabling NULL
authentication on the server socket so that it passes through your
handler for all connections. Then you have to count disconnections,
per endpoint.

Alternatively, create that restricted socket in a single dedicated context.

-Pieter

On Tue, Mar 17, 2015 at 4:56 PM, Auer, Jens <jens.auer at cgi.com> wrote:
> Hi,
>
>
>
> I am looking for a way to limit the number of connections to a configurable
> number. Our requirement says that for one specific endpoint, only a certain
> number of connections should be allowed. I hoped for socket option to do
> that, but I could not find any. Reading the documentation, I came up with
> the following ideas:
>
> -       Create a new context for the restricted endpoint and restrict the
> number of connections with ZMQ_MAX_SOCKETS.
>
> -       Install a socket monitor which monitors connect/disconnect events
> and counts active connections. When the number is exceeded, the new
> connection is closed immediately
>
> -       Install a socket monitor which monitors connect/disconnect events
> and counts active connections. When the number is reached, install a filter
> blocking every new connection until one of the connections is closed.
>
> Are there any other ways to do that? There is no real application-level
> protocol so I cannot close connections on that level. The application
> basically accepts connections and starts to send data immediately to anybody
> connecting.
>
>
>
> I would be grateful if anybody could comment on these methods. Personally, I
> prefer the first one because it seems to be simpler and relies only on
> zeroMQ defined behaviour.
>
>
>
> Best wishes,
>
>   Jens Auer
>
>
>
> --
>
> Jens Auer | CGI | Software Engineer
>
> CGI Deutschland Ltd. & Co. KG
> Rheinstraße 95 | 64295 Darmstadt | Germany
>
> T: +49 6151 36860 154
>
> jens.auer at cgi.com
>
> Unsere Pflichtangaben gemäß § 35a GmbHG / §§ 161, 125a HGB finden Sie unter
> de.cgi.com/pflichtangaben.
>
>
>
> CONFIDENTIALITY NOTICE: Proprietary/Confidential information belonging to
> CGI Group Inc. and its affiliates may be contained in this message. If you
> are not a recipient indicated or intended in this message (or responsible
> for delivery of this message to such person), or you think for any reason
> that this message may have been addressed to you in error, you may not use
> or copy or deliver this message to anyone else. In such case, you should
> destroy this message and are asked to notify the sender by reply e-mail.
>
>
>
>
> _______________________________________________
> 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