zmq.error.ZMQError : Address already in use

See original GitHub issue

Great job Jeff. Love this. As I’m using this in my scenario, I may need to sometimes deallocate the streamer and reallocate it depending upon the circumstances. I get this failure:

Traceback (most recent call last):
  File "src/detector.py", line 718, in async_stream_video
    REQ_REP=False)
  File "/usr/local/lib/python3.6/dist-packages/imagezmq/imagezmq.py", line 53, in __init__
    self.init_pubsub(connect_to)
  File "/usr/local/lib/python3.6/dist-packages/imagezmq/imagezmq.py", line 75, in init_pubsub
    self.zmq_socket.bind(address)
  File "zmq/backend/cython/socket.pyx", line 550, in zmq.backend.cython.socket.Socket.bind
  File "zmq/backend/cython/checkrc.pxd", line 26, in zmq.backend.cython.checkrc._check_rc
zmq.error.ZMQError: Address already in use

when I run this portion of my code more than once :

while True:
    video_streamer = imagezmq.ImageSender(connect_to=f'tcp://*:{target_port}', REQ_REP=False)
    # Do some work...
    video_streamer = None

Whenever it hits the 2nd line another time, I get the traceback above. Any idea how to specifically free this (I’m not myself familiar with pyzmq). But I would have imagined some kind of a context management :

with imagezmq.ImageSender(...) as sender:
   # do stuff

But I’m not seeing this in the source code, but if there’s missing cleanup code, we would need to implement that too. Thoughts? Did I miss something? Is there an easy way to clean up sockets from this object? thanks!

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
omartin2010commented, May 30, 2020

will do - for now I’m working on another section of my project, but I will get back to the one where I use the streaming soon, and I’ll update the code to use the with statement versus deleting the object. Thanks for the fix!

1reaction
omartin2010commented, Apr 27, 2020

Fixed my own issue:

video_streamer.zmq_socket.close()

Hope this can help someone. I think this is enough to make it work well, but I’ve not tested extensively. Enough for my project to work.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Recovering from zmq.error.ZMQError: Address already in use
Question 1: If you do sudo netstat -ltnp , on a Linux type operating system, you will most probably see the process owning...
Read more >
zmq.error.ZMQError: Address already in use · Issue #84 - GitHub
I'm newer for ZMQ, when I operated on the steps, I got this exception. It's not working even though retrying.
Read more >
Dash and ZMQ "address already in use" - Julia Discourse
Puzzled by this error message as nothing is running on the port for Dash (I run sudo netstat -nlp to make sure) and...
Read more >
ZMQ CANNOT BIND, ADDRESS ALREADY IN USE
Now am trying to run a simple application using ratchet and ZMQ after following the push tutorial but this is the error am...
Read more >
zmq.error.ZMQError: Address in use : r/flask - Reddit
Why am I getting this error? views.py from flask import Blueprint,render_template,request,Response from flask_login import login_required…
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found