pyzmq doesn't receive messages when using exec

12 views Asked by At

I would like to forward messages received from zmq.

A server is publishing messages via pyzmq to another computer in the same network. This computer has a script to subscribe these messages. When I execute the script using python3, I receive and display the messages. However, I would like to execute the following script to forward the messages to the Internet/or a third computer using this command: sudo ip netns exec ue1 python3 main.py -a 192.169.1.35. While executing the python script directly from the terminal I receive and prints the messages to the terminal, in the second case doesn't.

The code is:

import zmq
context = zmq.Context()
socket = context.socket(zmq.SUB)
socket.connect("tcp://10.1.24.50:4000")
socket.subscribe("")
print("subscribed")
while True:
    print("message rcv")    
    message = socket.recv_string()
    print(message)  

The python script has all the permissions 777 (just in case). My goal is to forward the message received via zmq from ue1 towards the network to the Internet/or another computer.

0

There are 0 answers