Catch conn reset (#159)

This commit is contained in:
david reid 2022-01-04 19:30:22 +00:00 committed by GitHub
parent 34180576ca
commit 8fcb3a58dd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 2 deletions

View File

@ -66,7 +66,7 @@ class APIPlaintextFrameHelper(APIFrameHelper):
_LOGGER.debug("Sending plaintext frame %s", data.hex())
self._writer.write(data)
await self._writer.drain()
except OSError as err:
except (ConnectionResetError, OSError) as err:
raise SocketAPIError(f"Error while writing data: {err}") from err
async def read_packet(self) -> Packet:

View File

@ -336,7 +336,7 @@ class APIConnection:
data=encoded,
)
)
except Exception as err: # pylint: disable=broad-except
except SocketAPIError as err: # pylint: disable=broad-except
# If writing packet fails, we don't know what state the frames
# are in anymore and we have to close the connection
await self._report_fatal_error(err)