Hi,

I am fairly new to using ZeroMQ. I want to setup a UDP communication
between two different devices. I understand that currently UDP is available
for only Radio/Dish sockets unless I want to use multicast. I installed the
ZeroMQ with the experimental draft API option and am able to setup a UDP
connection between radio-dish within the same device. However, the dish is
not connecting to the socket when they are across different devices.

To eliminate potential firewall issues, I checked the firewall settings and
enabled all ports for UDP and TCP communication, but the issue
still persists. This is the code for libzmq + pyzmq. I am getting a similar
issue for the implementation in C++ using libzmq & cppzmq as well.

*Server Code:*

import zmq
import signal
import sys

# Handle the interrupt signal to stop the client gracefully
def signal_handler(sig, frame):
    print('You pressed Ctrl+C! Exiting...')
    sys.exit(0)

signal.signal(signal.SIGINT, signal_handler)

unicast_url = "tcp://172.26.6.22:5556"
group = "unicast_test"

# Initialize the ZeroMQ context and socket
context = zmq.Context()
radio = context.socket(zmq.RADIO)

print("Connecting radio")
radio.connect(unicast_url)


message_num = 1
while True:
        try:
                print( "Sending message ", message_num)
                radio.send_string("Hello!", group = group)
                message_num += 1
        except zmq.ZMQError as e:
                if e.errno == zmq.ETERM:
                    break  # Interrupted
                else:
                    raise

print("Closing")
radio.close()
context.term()

---------------------------------------------

*Client Code:*

import zmq
import signal
import sys

# Handle the interrupt signal to stop the client gracefully
def signal_handler(sig, frame):
    print('You pressed Ctrl+C! Exiting...')
    sys.exit(0)

signal.signal(signal.SIGINT, signal_handler)

unicast_url = "udp://*:5556"
group = "unicast_test"

# Initialize the ZeroMQ context and socket
context = zmq.Context()
dish = context.socket(zmq.DISH)

print("Binding dish")
dish.bind(unicast_url)

print("Joining group")
dish.join(group)

print("Waiting for dish message")
while True:
    try:
        message = dish.recv_string()
        print(message)
    except zmq.ZMQError as e:
        if e.errno == zmq.ETERM:
            break  # Interrupted
        else:
            raise

print("Closing")
dish.close()
context.term()


-------------------------------------

Client output is stuck in the while loop waiting for a message from the
server, so I believe the connection is not established.


What am I missing to establish a UDP communication between two different
devices? Any help would be appreciated. Thank you!


Regards,
Suresh.
_______________________________________________
zeromq-dev mailing list
[email protected]
https://lists.zeromq.org/mailman/listinfo/zeromq-dev

Reply via email to