How to deal with multiple publishers on one port in zmq?
This question was asked earlier, here . I have exactly the same problem. I want to publish from many different processes and use the same port every time.
I tried the solution provided in the answer, but it didn't work for me. I get an error
File "/usr/local/lib/python2.7/multiprocessing/process.py", line 258, in _bootstrap
self.run()
File "/usr/local/lib/python2.7/multiprocessing/process.py", line 114, in run
self._target(*self._args, **self._kwargs)
File "/home/akay/afk/multi.py", line 18, in to_zmq
socket.connect("tcp://*:%s" % port)
File "zmq/backend/cython/socket.pyx", line 478, in zmq.backend.cython.socket.Socket.connect (zmq/backend/cython/socket.c:4308)
ZMQError: Invalid argument
My code is similar to this, essentially straight from the example in the zmq docs here and here :
# Socket to talk to server
port = '5556'
context = zmq.Context()
socket = context.socket(zmq.SUB)
print "Listening for stream...", m
socket.bind("tcp://localhost:%s" % port) #change connect to bind, as per answer above
socket.setsockopt(zmq.SUBSCRIBE, topicfilter)
I am using python 2.7 and latest zmq. Any idea what I might be doing wrong?
+3
Wapiti
source
to share
1 answer
Well the error is clear:
[...]
socket.connect("tcp://*:%s" % port)
[...]
ZMQError: Invalid argument
You cannot connect to *
, you must provide an IP address (server IP address). If the client and server are running on the same computer, try using localhost
or 127.0.0.1
.
+3
Peque
source
to share