瀏覽代碼

fix(device): ensure persistent connection is reestablished after error

When the persistent connection has been closed due to an error, ensure that
this is detected and the persistent connection reestablished next time
around the receive loop.

Issue #6112, originally #6054 which was reverted in the last commit.
Jason Rumney 1 月之前
父節點
當前提交
899a4eb85d
共有 1 個文件被更改,包括 3 次插入 和 1 次删除
  1. 3 1
      custom_components/tuya_local/device.py

+ 3 - 1
custom_components/tuya_local/device.py

@@ -350,7 +350,9 @@ class TuyaLocalDevice(object):
                 last_cache = self._cached_state.get("updated_at", 0)
                 now = time()
                 full_poll = False
-                if persist == self.should_poll:
+                if (persist == self.should_poll) or (
+                    persist and (self._api.socket is None)
+                ):
                     # use persistent connections after initial communication
                     # has been established.  Until then, we need to rotate
                     # the protocol version, which seems to require a fresh