ZeroMQ, how to connect to external tcp socket?
Asked Answered
F

2

6

Can you please tell me how you can use to send messages ZeroMQ between two programs located on different servers using some common socket? With all local sockets program works, but I do not understand how they spread to different places. Because climbs error:

Traceback (most recent call last):
  File "/Users/*****/Projects/*****/workers/internal_links_parser.py", line 20, in <module>
    socket.bind("tcp://***.***.***.***:5000")
  File "socket.pyx", line 447, in zmq.core.socket.Socket.bind (zmq/core/socket.c:4312)
zmq.core.error.ZMQError: Can't assign requested address

Explain, please, and if not difficult to give an example. Thx!

Fraya answered 24/1, 2013 at 21:30 Comment(1)
You saved my time for asking this question again ! thanksPopulate
B
9

From the zmq socket manual on Socket.bind;

This causes the socket to listen on a network port. Sockets on the other side of this connection will use Socket.connect(addr) to connect to this socket.

In other words, this will tell 0mq to listen to a local port for incoming connections; you should use something like socket.bind("tcp://0.0.0.0:5000") to listen to all of the machine's IP addresses on port 5000.

The other side of the connection should use Socket.connect with an URL something like socket.connect("tcp://remoteip:5000") to connect to the other side listening.

It would seem from the error message that you're trying to bind to the remote address instead of binding to the local and connecting to the remote.

Burks answered 24/1, 2013 at 21:41 Comment(0)
P
3

Don't forget to check the firewall. It should be inactive.

Also, you can check to know if the server is accessible or not with telnet:

telnet serverIPaddress serverPortNo
Panne answered 4/2, 2015 at 15:57 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.