Skip to content

Commit

Permalink
Add grace period to Websocket Timeout (#372)
Browse files Browse the repository at this point in the history
  • Loading branch information
shbatm authored Jan 20, 2023
1 parent 5c34a2c commit 2344d08
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions pyisy/events/websocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"Origin": "com.universal-devices.websockets.isy",
}
WS_HEARTBEAT = 30
WS_HB_GRACE = 2
WS_TIMEOUT = 10.0
WS_MAX_RETRIES = 4
WS_RETRY_BACKOFF = [0.01, 1, 10, 30, 60] # Seconds
Expand Down Expand Up @@ -149,7 +150,7 @@ async def _websocket_guardian(self):
if (
self.websocket_task.cancelled()
or self.websocket_task.done()
or self.heartbeat_time > self._hbwait
or self.heartbeat_time > self._hbwait + WS_HB_GRACE
):
_LOGGER.debug("Websocket missed a heartbeat, resetting connection.")
self.status = ES_LOST_STREAM_CONNECTION
Expand Down Expand Up @@ -220,7 +221,7 @@ async def websocket(self, retries=0):
heartbeat=WS_HEARTBEAT,
headers=WS_HEADERS,
timeout=WS_TIMEOUT,
receive_timeout=self._hbwait,
receive_timeout=self._hbwait + WS_HB_GRACE,
ssl=self.sslcontext,
) as ws:
self.status = ES_CONNECTED
Expand Down

0 comments on commit 2344d08

Please sign in to comment.