Skip to content

Commit

Permalink
Add failed ConnectionState
Browse files Browse the repository at this point in the history
  • Loading branch information
owenpearson committed Sep 14, 2022
1 parent b8f3c9a commit fce2edf
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
2 changes: 2 additions & 0 deletions ably/realtime/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class ConnectionState(Enum):
CONNECTED = 'connected'
CLOSING = 'closing'
CLOSED = 'closed'
FAILED = 'failed'


class RealtimeConnection:
Expand Down Expand Up @@ -68,6 +69,7 @@ async def ws_read_loop(self):
if action == 9: # ERROR
error = msg["error"]
if error['nonfatal'] is False:
self.__state = ConnectionState.FAILED
if self.__connected_future:
self.__connected_future.set_exception(
AblyAuthException(error["message"], error["statusCode"], error["code"]))
Expand Down
1 change: 1 addition & 0 deletions test/ably/realtimeconnection_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,5 @@ async def test_auth_invalid_key(self):
ably = await RestSetup.get_ably_realtime(key=self.valid_key_format)
with pytest.raises(AblyAuthException):
await ably.connect()
assert ably.connection.state == ConnectionState.FAILED
await ably.close()

0 comments on commit fce2edf

Please sign in to comment.