Add heartbeat to zmq socket

It was identified that when the remote RPC server is restarted, 
the RPC client did not automatically reconnected and then the
first attempt of a cast message was not received by the remote 
RPC server. Only after a second cast message was sent that the 
remote connection was restablished. 

Configuring the zmq socket with HEARTBEAT_IVL solves the issue. 

Test Plan (AIO-DX):
PASS: build pkgs and build ISO
PASS: Install ISO and bootstrap
PASS: Verify that zerorpc/events.py file is updated
PASS: lock/unlock inactive controller
PASS: system host-device-image-update controller-1

Closes-Bug: 2101879

Change-Id: Ie7b75ae236e32f7a0d2f0147082134eafa363d09
Signed-off-by: Alyson Deives Pereira <alyson.deivespereira@windriver.com>
This commit is contained in:
Alyson Deives Pereira 2025-03-10 12:48:33 -03:00
parent 001168a2f1
commit 3f422f5dc0
2 changed files with 27 additions and 1 deletions

View File

@ -0,0 +1,25 @@
From 7b05c1388f2bf21309e7e7b45a8087b08b0d181e Mon Sep 17 00:00:00 2001
From: Alyson Deives Pereira <alyson.deivespereira@windriver.com>
Date: Mon, 10 Mar 2025 11:14:09 -0300
Subject: [PATCH] Add heartbeat to zmq socket
Signed-off-by: Alyson Deives Pereira <alyson.deivespereira@windriver.com>
---
zerorpc/events.py | 1 +
1 file changed, 1 insertion(+)
diff --git a/zerorpc/events.py b/zerorpc/events.py
index a0de3f0..3ba8354 100644
--- a/zerorpc/events.py
+++ b/zerorpc/events.py
@@ -253,6 +253,7 @@ class Events(ChannelBase):
self._context = context or Context.get_instance()
self._socket = self._context.socket(zmq_socket_type)
self._socket.setsockopt(zmq.IPV6, True)
+ self._socket.setsockopt(zmq.HEARTBEAT_IVL, 5000)
self._encoder = encoder
self._decoder = decoder
--
2.34.1

View File

@ -5,4 +5,5 @@
0005-Fix-kwargs-when-internal-opts-are-present.patch
0006-Refactor-the-use-of-triggers-in-tests.patch
0007-Add-IPV6-support.patch
0008-Change-unable-to-route-event-message-log-level-to-de.patch
0008-Change-unable-to-route-event-message-log-level-to-de.patch
0009-Add-heartbeat-to-zmq-socket.patch