[zeromq-dev] Any way to flush or clear or manage ports?
Gary Davidson
Gary.Davidson at interclick.com
Tue Sep 6 03:06:22 CEST 2011
Hi Marc
I think you are looking for termites in an igloo :)
I have never seen this in production windows servers (rapidly starting and stopping a process over and over gets ops guys fired) and I have had just about every other TCP problem you can have in Windows.
If you need a tool to fix this because it happens repeatedly then there is another bigger issue you need to solve.
-g
[Description: Description: Description: Description: C:\Users\sam.mueller\AppData\Roaming\Microsoft\Signatures\interclick signature_files\logo.png]
Gary Davidson, Chief Software Architect
gary.davidson at interclick.com<mailto:gary.davidson at interclick.com>
P 561 300 2764
C 954 790 0715
F 561 300 2765
4800 T-Rex Ave
Suite 120
Boca Raton, FL 33431
www.interclick.com
NASDAQ: ICLK
From: zeromq-dev-bounces at lists.zeromq.org [mailto:zeromq-dev-bounces at lists.zeromq.org] On Behalf Of Marc Ilgen
Sent: Sunday, September 04, 2011 6:56 PM
To: 'ZeroMQ development list'
Subject: Re: [zeromq-dev] Any way to flush or clear or manage ports?
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<mailto:marc at westofpluto.com>
________________________________
From: zeromq-dev-bounces at lists.zeromq.org<mailto:zeromq-dev-bounces at lists.zeromq.org> [mailto:zeromq-dev-bounces at lists.zeromq.org]<mailto:[mailto: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<mailto: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<mailto:zeromq-dev-request at lists.zeromq.org>> wrote:
Send zeromq-dev mailing list submissions to
zeromq-dev at lists.zeromq.org<mailto: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<mailto:zeromq-dev-request at lists.zeromq.org>
You can reach the person managing the list at
zeromq-dev-owner at lists.zeromq.org<mailto: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<mailto:sustrik at 250bpm.com>>
Subject: Re: [zeromq-dev] Any way to flush or clear or manage ports?
To: ZeroMQ development list <zeromq-dev at lists.zeromq.org<mailto:zeromq-dev at lists.zeromq.org>>
Cc: Marc Ilgen <marc at westofpluto.com<mailto:marc at westofpluto.com>>
Message-ID: <4E630D95.3060100 at 250bpm.com<mailto:4E630D95.3060100 at 250bpm.com>>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
On 09/03/2011 07:18 PM, Marc Ilgen wrote:
> I'm using Windows Vista, and using version 2.1.7 of 0MQ. I'd like to get a
> solution that clears ports on any modern Windows system (Win7, Vista, XP)
Two thoughts:
1. Aren't you running the listining process in the debugger? In theory,
when it fails under debugger it may not correctly release all listening
ports as the debugging process doesn't really exit.
2. It may be some windows-specific behaviour. In any case try checking
which process uses the port (eg. "netstat -o -n -a | findstr :80" and
look up the process ID in the task manager).
Martin
------------------------------
Message: 2
Date: Sat, 3 Sep 2011 23:55:25 -0700
From: Elliot Saba <staticfloat at gmail.com<mailto:staticfloat at gmail.com>>
Subject: Re: [zeromq-dev] Any way to flush or clear or manage ports?
To: ZeroMQ development list <zeromq-dev at lists.zeromq.org<mailto:zeromq-dev at lists.zeromq.org>>
Cc: Marc Ilgen <marc at westofpluto.com<mailto:marc at westofpluto.com>>
Message-ID:
<CAGGi21Zdf2OvDydXqHm9yUWo3zGC01XN4kAhBZn3UusAsfA7Ow at mail.gmail.com<mailto:CAGGi21Zdf2OvDydXqHm9yUWo3zGC01XN4kAhBZn3UusAsfA7Ow at mail.gmail.com>>
Content-Type: text/plain; charset="iso-8859-1"
Hello, Marc, in addition, I suggest you read up on the SO_REUSEADDR (On
linux, there is also a SO_REUSEPORT option, but SO_REUSEADDR should do the
same thing on windows) socket option, and if that looks like your problem,
maybe try modifying the sources to use that option when creating a socket.
-E
On Sat, Sep 3, 2011 at 10:33 PM, Martin Sustrik <sustrik at 250bpm.com<mailto:sustrik at 250bpm.com>> wrote:
> On 09/03/2011 07:18 PM, Marc Ilgen wrote:
> > I'm using Windows Vista, and using version 2.1.7 of 0MQ. I'd like to get
> a
> > solution that clears ports on any modern Windows system (Win7, Vista, XP)
>
> Two thoughts:
>
> 1. Aren't you running the listining process in the debugger? In theory,
> when it fails under debugger it may not correctly release all listening
> ports as the debugging process doesn't really exit.
>
> 2. It may be some windows-specific behaviour. In any case try checking
> which process uses the port (eg. "netstat -o -n -a | findstr :80" and
> look up the process ID in the task manager).
>
> Martin
> _______________________________________________
> zeromq-dev mailing list
> zeromq-dev at lists.zeromq.org<mailto:zeromq-dev at lists.zeromq.org>
> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.zeromq.org/pipermail/zeromq-dev/attachments/20110903/85fd102d/attachment.html
------------------------------
Message: 3
Date: Sun, 04 Sep 2011 09:52:37 +0200
From: Martin Sustrik <sustrik at 250bpm.com<mailto:sustrik at 250bpm.com>>
Subject: Re: [zeromq-dev] Any way to flush or clear or manage ports?
To: ZeroMQ development list <zeromq-dev at lists.zeromq.org<mailto:zeromq-dev at lists.zeromq.org>>
Cc: Marc Ilgen <marc at westofpluto.com<mailto:marc at westofpluto.com>>, Elliot Saba
<staticfloat at gmail.com<mailto:staticfloat at gmail.com>>
Message-ID: <4E632E45.50805 at 250bpm.com<mailto:4E632E45.50805 at 250bpm.com>>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
On 09/04/2011 08:55 AM, Elliot Saba wrote:
> Hello, Marc, in addition, I suggest you read up on the SO_REUSEADDR (On
> linux, there is also a SO_REUSEPORT option, but SO_REUSEADDR should do
> the same thing on windows) socket option, and if that looks like your
> problem, maybe try modifying the sources to use that option when
> creating a socket.
The following code is responsible for tuning the listening socket:
// Allow reusing of the address.
int flag = 1;
#ifdef ZMQ_HAVE_WINDOWS
rc = setsockopt (s, SOL_SOCKET, SO_EXCLUSIVEADDRUSE,
(const char*) &flag, sizeof (int));
wsa_assert (rc != SOCKET_ERROR);
#else
rc = setsockopt (s, SOL_SOCKET, SO_REUSEADDR, &flag, sizeof (int));
errno_assert (rc == 0);
#endif
I guess the WINDOWS part may be wrong.
Can anyone with win experience comment?
Martin
------------------------------
Message: 4
Date: Sun, 04 Sep 2011 10:29:05 +0200
From: Martin Sustrik <sustrik at 250bpm.com<mailto:sustrik at 250bpm.com>>
Subject: Re: [zeromq-dev] Option for choosing polling system
To: ZeroMQ development list <zeromq-dev at lists.zeromq.org<mailto:zeromq-dev at lists.zeromq.org>>
Cc: Mikko Koppanen <mikko.koppanen at gmail.com<mailto:mikko.koppanen at gmail.com>>
Message-ID: <4E6336D1.6060604 at 250bpm.com<mailto:4E6336D1.6060604 at 250bpm.com>>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
On 09/03/2011 05:16 PM, Mikko Koppanen wrote:
> Added option to choose internal polling system
Applied to the trunk.
Thanks!
Martin
------------------------------
_______________________________________________
zeromq-dev mailing list
zeromq-dev at lists.zeromq.org<mailto:zeromq-dev at lists.zeromq.org>
http://lists.zeromq.org/mailman/listinfo/zeromq-dev
End of zeromq-dev Digest, Vol 45, Issue 12
******************************************
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20110906/f27eb847/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image002.jpg
Type: image/jpeg
Size: 1810 bytes
Desc: image002.jpg
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20110906/f27eb847/attachment.jpg>
More information about the zeromq-dev
mailing list