From 0a41196540044d074bc8d68c666d3efb6c66e0fc Mon Sep 17 00:00:00 2001 From: Jiachen Dong Date: Tue, 9 Aug 2022 09:18:21 +0800 Subject: [PATCH] [thci] add SSH keepalive (#7999) Add SSH keepalive to avoid disconnection after idle for a long time. --- tools/harness-thci/OpenThread_BR.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tools/harness-thci/OpenThread_BR.py b/tools/harness-thci/OpenThread_BR.py index 160d57616..34fba1a2e 100644 --- a/tools/harness-thci/OpenThread_BR.py +++ b/tools/harness-thci/OpenThread_BR.py @@ -60,6 +60,8 @@ logging.getLogger('paramiko').setLevel(logging.WARNING) class SSHHandle(object): + # Unit: second + KEEPALIVE_INTERVAL = 30 def __init__(self, ip, port, username, password): self.ip = ip @@ -85,6 +87,9 @@ class SSHHandle(object): else: raise + # Avoid SSH disconnection after idle for a long time + self.__handle.get_transport().set_keepalive(self.KEEPALIVE_INTERVAL) + def close(self): if self.__handle is not None: self.__handle.close()