mirror of
https://github.com/esphome/aioesphomeapi.git
synced 2024-11-22 12:05:12 +01:00
Catch conn reset (#159)
This commit is contained in:
parent
34180576ca
commit
8fcb3a58dd
@ -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:
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user