[zeromq-dev] Any way to flush or clear or manage ports?

Pieter Hintjens ph at imatix.com
Tue Sep 6 00:40:49 CEST 2011


Marc,

There are two scenarios that I know of which will cause the problems you're
seeing. One, you have a server process lying around still occupying the
port, and preventing new processes from binding to it. You can check this
using "netstat -a" from the command line. Scenario two: if a client doesn't
disconnect, the port may be held busy in a TIMEOUT state and the OS may stop
a server binding to it, usually for 30 minutes iirc. But afaik this happens
on Unix/Linux, not on Windows. Again, "netstat -a" is your friend.

If you can reproduce the problem with a minimal test case, we can
investigate. I'm very sure this is not a 0MQ issue at all, but due to your
server process hanging around and/or the socket being held in a TIMEOUT
state.

-Pieter

On Monday, September 5, 2011, Marc Ilgen wrote:

> ** **
>
> Hi Folks****
>
> Thanks for the comments but I’m worried we are going down the wrong path
> here. Yes it would be great if those of you who know the internals could
> tweak the ZeroMQ library code and prevent the problem in the first place.
> But what I’m looking for is something different. Let me explain.****
>
> ** **
>
> In the vast majority of cases, this problem will never occur. However, if
> someone (either me during debugging or a customer who is using my eventual
> commercial product) keeps starting and stopping a process improperly for
> whatever reason, then it may be the case that the port it is being used on
> becomes unavailable, and zmq_bind fails. I need to have a handy utility
> program just in case that solves the problem.****
>
> ** **
>
> What I am looking for is a solution for what I (or my customer) can do in
> this situation. Specifically, I want to kill whatever process is clogging up
> that port and/or reset whatever parameters that port has so that it can be
> used again. I want to be able to write either a shell script (BAT file for
> windows) that does this or write some ZMQ C/C++ code (a separate program
> from my product) that I can just run to cleanup whatever problem exists on
> that port. I’m not looking for a one-off solution like manually editing my
> Windows registry settings or manually executing some series of OS commands
> so it works just on my specific computer.****
>
> ** **
>
> It is kind of like killing termites in a house. I don’t want to find each
> individual termite and understand its behavior and modify the behavior of
> the individual termite. I just want to tent the house and kill every termite
> inside. So if something is clogged up on port 5558, I want to run some
> simple code/script that just kills/resets whatever it finds regarding port
> 5558 so I can use it again.****
>
> ** **
>
> Isn’t there some way to do this without rebooting the machine?****
>
> ** **
>
> Also, if this port lockup occurs, is there some period of time after which
> the problem should disappear? Or will it stay this way forever until the
> system reboots? ****
>
> ** **
>
> Marc****
>
>
> ----------------------------------------------------------------------------------
> ****
>
> Marc Ilgen****
>
> marc at westofpluto.com <javascript:_e({}, 'cvml', 'marc at westofpluto.com');>*
> ***
>
> ** **
>  ------------------------------
>
> *From:* zeromq-dev-bounces at lists.zeromq.org <javascript:_e({}, 'cvml',
> 'zeromq-dev-bounces at lists.zeromq.org');> [mailto:
> zeromq-dev-bounces at lists.zeromq.org <javascript:_e({}, 'cvml',
> 'zeromq-dev-bounces at lists.zeromq.org');>] *On Behalf Of *Scott Asher
> *Sent:* Sunday, September 04, 2011 5:25 AM
> *To:* zeromq-dev at lists.zeromq.org <javascript:_e({}, 'cvml',
> 'zeromq-dev at lists.zeromq.org');>
> *Subject:* Re: [zeromq-dev] Any way to flush or clear or manage ports?****
>
> ** **
>
> Hi guys,****
>
> ** **
>
> While I am not a real expert, my understanding is this:****
>
> ** **
>
> Windows does not follow BSD semantics with respect to SO_REUSEADDR.
>  Specifically, SO_REUSEADDR allows multiple processes to bind to the same
> port on a single interface, resulting in indeterministic behavior with
> respect to who gets what packets.  Why MSFT made this design decision, I am
> not sure, but SO_EXCLUSIVEADDRUSE is supposed to result in behavior more
> similar to BSD-style, but in practice it doesn't work out that way.  I don't
> think there is a perfect solution here.  My suggestion is that we not change
> the Windows implementation back to use SO_REUSEADDR because that will just
> make everyone's life hell with respect to debugging (at least you KNOW why
> code that can't bind to a port is failing).  ONe additional suggestion for
> Windows users is to tweak the TcpTimedWaitDelay registry setting found at:
> ****
>
> ** **
>
> *HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters****
> *
>
> ** **
>
> I think you can set it as low as 30s and the default is 120s, so 30s will
> be much less annoying if you are constantly creating/deleting listening
> sockets.****
>
> ** **
>
> Scott****
>
> ** **
>
> On Sun, Sep 4, 2011 at 6:00 AM, <zeromq-dev-request at lists.zeromq.org>
> wrote:****
>
> Send zeromq-dev mailing list submissions to
>        zeromq-dev at lists.zeromq.org
>
> To subscribe or unsubscribe via the World Wide Web, visit
>        http://lists.zeromq.org/mailman/listinfo/zeromq-dev
> or, via email, send a message with subject or body 'help' to
>        zeromq-dev-request at lists.zeromq.org
>
> You can reach the person managing the list at
>        zeromq-dev-owner at lists.zeromq.org
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of zeromq-dev digest..."
>
>
> Today's Topics:
>
>   1. Re: Any way to flush or clear or manage ports? (Martin Sustrik)
>   2. Re: Any way to flush or clear or manage ports? (Elliot Saba)
>   3. Re: Any way to flush or clear or manage ports? (Martin Sustrik)
>   4. Re: Option for choosing polling system (Martin Sustrik)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Sun, 04 Sep 2011 07:33:09 +0200
> From: Martin Sustrik <sustrik at 250bpm.com>
> Subject: Re: [zeromq-dev] Any way to flush or clear or manage ports?
> To: **ZeroMQ developm
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20110906/9825b793/attachment.htm>


More information about the zeromq-dev mailing list