Reputation: 1
3 Raspberry Pis involved here running ZMQ publish and subscribe.
I have one running a pump in the cellar, one as a monitor upstairs showing LEDs for state of pump. They send heartbeats to each other to make sure both are up and well.
The third is a diagnostic spy just subscribing to any sends from the other two. If the monitor restarts, the spy loses its subscription to the monitor messages. On restart of spy all is well and it picks up the messages again.
I saw something about this from about 10 years ago - does anyone have more recent information/advice?
The only fix I have found so far is a restart of the spy program. I am tempted by some sort of re-subscribe but have seen cautions about having to cancel existing subscriptions and keep count of them .
This is what the spy does at startup .... using parameters from common code.
>
> def zeromq_init():
> in_context1 = zmq.Context()
> ZMQdata.in_socket1 = in_context1.socket(zmq.SUB)
> subscribe_to = f"tcp://{PUMP_ADDR}:{PUMP_TO_MONITOR_PORT}"
> ZMQdata.in_socket1.connect(subscribe_to) ## subscribe to pump
> ZMQdata.in_socket1.setsockopt_string(zmq.SUBSCRIBE,"")
>
> in_context2 = zmq.Context()
> ZMQdata.in_socket2 = in_context2.socket(zmq.SUB)
> subscribe_to = f"tcp://{MONITOR_ADDR}:{MONITOR_TO_PUMP_PORT}"
> ZMQdata.in_socket2.connect(subscribe_to) ## subscribe to monitor
> ZMQdata.in_socket2.setsockopt_string(zmq.SUBSCRIBE,"")
>
>
Upvotes: 0
Views: 36