0

Trying to use EPGM with ZeroMQ, PUB/SUB pattern, but can't receive message on client side. How to fix code? I am running this code on Ubuntu with wireless connection.

wlp2s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.1.122 netmask 255.255.255.0 broadcast 192.168.1.255

ip maddr show (Multicast addresses) inet 224.0.0.251 users 2 inet 224.0.0.1

publisher:

    context = zmq.Context()
    context.set(zmq.IO_THREADS, 1)
    socket = context.socket(zmq.PUB)
    socket.bind("epgm://192.168.1.122;224.0.0.251:5555")

    # Allow clients to connect before sending data

    while True:

        data = struct.pack("q", time.perf_counter_ns())
        socket.send(data)
        print(data)

subscriber:

    context = zmq.Context()
    context.set(zmq.IO_THREADS, 1)
    socket = context.socket(zmq.SUB)

    socket.connect("epgm://192.168.1.122;224.0.0.251:5555")

    socket.setsockopt(zmq.SUBSCRIBE, b"")

    while True:
        data = socket.recv()
        print(data)
        numbers.append((time.perf_counter_ns(), data))
Sergey Ko
  • 11
  • 2

1 Answers1

0

It looks like you are running both the publisher and subscriber on the same host (based on the interface ip), zeromq EPGM does not support loopback

since version 3 the support/option was removed https://github.com/zeromq/libzmq/blob/master/NEWS#L17642

Try between two hosts if possible.

I hit this issue in the past for a large system and ended up binding the pub socket to both epgm and ipc to allow localhost subscribers also.

James Harvey
  • 912
  • 4
  • 6
  • I have one publisher and several subscriber processes on the same host to reliably send and receive multicast messages. Thus I'm using the following bind and connect expression: publisher.bind("epgm://localhost:5555"); subscriber.connect("epgm://localhost:5555");. All subscriber processes receive the data sent by the publisher. However, I receive the following warnings: "Warn: Interface lo reports as a loopback device" and "Warn: Interface lo reports as a non-multicast capable device" But so far it works for me. I wonder, why it doesn't work for you...?! OpenPGM-5.3.0 is used. – Degoah Jul 10 '23 at 11:39