From dd229dc8cf777a45b41ac951fbecaf2a821be7ab Mon Sep 17 00:00:00 2001 From: samson0v Date: Wed, 15 Mar 2023 10:02:26 +0200 Subject: [PATCH] Added timeout error catching for TCP connection --- src/paho/mqtt/client.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/paho/mqtt/client.py b/src/paho/mqtt/client.py index 54405a4e..8c9dca5d 100644 --- a/src/paho/mqtt/client.py +++ b/src/paho/mqtt/client.py @@ -2415,6 +2415,10 @@ def _packet_read(self): self._easy_log( MQTT_LOG_ERR, 'failed to receive on socket: %s', err) return MQTT_ERR_CONN_LOST + except TimeoutError as err: + self._easy_log( + MQTT_LOG_ERR, 'timeout on socket: %s', err) + return MQTT_ERR_CONN_LOST else: if len(command) == 0: return MQTT_ERR_CONN_LOST