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!
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.
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.
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.
ZeroMQ is an asynchronous network messaging library known for its high performance.
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With