Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ZeroMQ, how to connect to external tcp socket?

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!

like image 371
Ellochka Cannibal Avatar asked Jan 24 '13 21:01

Ellochka Cannibal


People also ask

Does ZeroMQ use sockets?

ZeroMQ patterns are implemented by pairs of sockets with matching types. The built-in core ZeroMQ patterns are: Request-reply, which connects a set of clients to a set of services. This is a remote procedure call and task distribution pattern.

Does ZeroMQ use TCP?

MQTT requires TCP/IP, whereas ZeroMQ can use a number of underlying transports, including UDP and shared memory. But still for ZeroMQ, TCP/IP is the primary transport used for inter-machine communication.

What is ZeroMQ socket?

ZeroMQ (also known as ØMQ, 0MQ, or zmq) looks like an embeddable networking library but acts like a concurrency framework. It gives you sockets that carry atomic messages across various transports like in-process, inter-process, TCP, and multicast.

Is ZeroMQ asynchronous?

ZeroMQ is an asynchronous network messaging library known for its high performance.


2 Answers

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.

like image 65
Joachim Isaksson Avatar answered Sep 18 '22 12:09

Joachim Isaksson


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
like image 36
Aboozar Rajabi Avatar answered Sep 18 '22 12:09

Aboozar Rajabi