Fix disconnect message not being sent when disconnecting during hello phase (#396)

This commit is contained in:
J. Nick Koston 2023-03-05 18:52:55 -10:00 committed by GitHub
parent f2e1942666
commit 81f6e67038
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 2 deletions

View File

@ -645,8 +645,11 @@ class APIConnection:
await self.send_message_await_response(PingRequest(), PingResponse)
async def disconnect(self) -> None:
if self._connection_state != ConnectionState.CONNECTED:
# already disconnected
if not self._is_socket_open or not self._frame_helper:
# We still want to send a disconnect request even
# if the hello phase isn't finished to ensure we
# the esp will clean up the connection as soon
# as possible.
return
self._expected_disconnect = True