-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Handle ZMQError "Address already in use" #30
base: main
Are you sure you want to change the base?
Conversation
I'm ignoring CodeFactor and Stickler complaints, they are something that should be handled in a separate test refactoring PR. |
How about syncing with the linger timeout? Because I think this is the reason the bind fails. |
What does "linger timeout" mean? |
We set the linger timeout here: https://github.com/pytroll/posttroll/blob/master/posttroll/publisher.py#L143 Basically that's how much time we give the socket to shut off all connections cleanly, and it's set here to one second. And I suspect that's why you get the error in the first place, since the previous connection doesn't have time to shut down cleanly before you create a new one one the same port. |
This page says the timeout is in milliseconds: http://api.zeromq.org/2-1:zmq-setsockopt At the moment I'm still having occasional problems with 2 second (10 x 0.2 seconds) wait. |
oh, ok. Then I suppose TIME_WAIT is the culprit. Not too much we can do about that. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for adding this. Some inline comments.
I started to make the requested changes and add tests, but have come to the conclusion that this won't really solve the problem I've been having. So, instead of defining the port, I now let the Trollflow2 publisher to have any free port from a given range by defining I can still finish this PR if it is seen to be usable, IIRC I have only one of the suggestions unfinished. @mraspaud? |
Pushed the changes in any case, but will convert to a Draft PR. |
This PR fixes an occasional
zmq.error.ZMQError: Address already in use
I get in Trollflow2. This happens when a new publisher is created with the same port as the one closed immediately before and OS hasn't had time to free the port.Minimal code that shows the error with current
master
branch: