Skip to content

Commit

Permalink
Merge pull request #20 from bretterer/unauthenticated
Browse files Browse the repository at this point in the history
Stop reconnecting websocket if unauthenticated
  • Loading branch information
natekspencer authored May 25, 2023
2 parents b3379a5 + a268444 commit 1132c62
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "rivian-python-client"
version = "0.2.2"
version = "0.2.3"
description = "Rivian API Client (Unofficial)"
readme = "README.md"
authors = ["Brian Retterer <[email protected]>"]
Expand Down
4 changes: 3 additions & 1 deletion src/rivian/ws_monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ async def _receiver(self) -> None:
msg = await websocket.receive(timeout=60)
if msg.type in (WSMsgType.CLOSE, WSMsgType.CLOSING, WSMsgType.CLOSED):
self._log_message(msg)
if msg.extra == "Unauthenticated":
self._disconnect = True
break
self._last_received = datetime.now(timezone.utc)
if msg.type == WSMsgType.TEXT:
Expand All @@ -156,7 +158,7 @@ async def _monitor(self) -> None:
"""Monitor a web socket connection."""
attempt = 0
while not self._disconnect:
while self.connected or not self._subscriptions:
while self.connected:
if self._receiver_task.done(): # Need to restart the receiver
self._receiver_task = asyncio.ensure_future(self._receiver())
await asyncio.sleep(1)
Expand Down

0 comments on commit 1132c62

Please sign in to comment.