Broken pipe error

After updating to 118 i sometime receive this couple of errors:

BrokenPipeError: [Errno 32] Broken pipe
ConnectionResetError: Cannot write to closing transport

When this happen, the front end is not accessible for some 30-40 seconds or even more (not clear to me). Looks like a restart of home assistant is needed to fix the situation.

Any idea on how to solve or what could be the cause of this?

Thank you in advance.

The complete errors in the log:

2020-12-11 22:14:06 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.9/site-packages/aiohttp/web_protocol.py", line 422, in _handle_request
    resp = await self._request_handler(request)
  File "/srv/homeassistant/lib/python3.9/site-packages/aiohttp/web_app.py", line 499, in _handle
    resp = await handler(request)
  File "/srv/homeassistant/lib/python3.9/site-packages/aiohttp/web_middlewares.py", line 118, in impl
    return await handler(request)
  File "/srv/homeassistant/lib/python3.9/site-packages/homeassistant/components/http/forwarded.py", line 71, in forwarded_middleware
    return await handler(request)
  File "/srv/homeassistant/lib/python3.9/site-packages/homeassistant/components/http/request_context.py", line 18, in request_context_middleware
    return await handler(request)
  File "/srv/homeassistant/lib/python3.9/site-packages/homeassistant/components/http/ban.py", line 72, in ban_middleware
    return await handler(request)
  File "/srv/homeassistant/lib/python3.9/site-packages/homeassistant/components/http/auth.py", line 127, in auth_middleware
    return await handler(request)
  File "/srv/homeassistant/lib/python3.9/site-packages/homeassistant/components/http/view.py", line 129, in handle
    result = await result
  File "/srv/homeassistant/lib/python3.9/site-packages/homeassistant/components/websocket_api/http.py", line 42, in get
    return await WebSocketHandler(request.app["hass"], request).async_handle()
  File "/srv/homeassistant/lib/python3.9/site-packages/homeassistant/components/websocket_api/http.py", line 233, in async_handle
    await self._writer_task
  File "/srv/homeassistant/lib/python3.9/site-packages/homeassistant/components/websocket_api/http.py", line 81, in _writer
    await self.wsock.send_str(message)
  File "/srv/homeassistant/lib/python3.9/site-packages/aiohttp/web_ws.py", line 300, in send_str
    await self._writer.send(data, binary=False, compress=compress)
  File "/srv/homeassistant/lib/python3.9/site-packages/aiohttp/http_websocket.py", line 687, in send
    await self._send_frame(message, WSMsgType.TEXT, compress)
  File "/srv/homeassistant/lib/python3.9/site-packages/aiohttp/http_websocket.py", line 656, in _send_frame
    await self.protocol._drain_helper()
  File "/srv/homeassistant/lib/python3.9/site-packages/aiohttp/base_protocol.py", line 87, in _drain_helper
    await waiter
  File "/usr/local/lib/python3.9/asyncio/selector_events.py", line 943, in _write_ready
    n = self._sock.send(self._buffer)
BrokenPipeError: [Errno 32] Broken pipe
2020-12-11 22:14:29 WARNING (MainThread) [homeassistant.components.device_tracker] Updating device list from legacy took longer than the scheduled scan interval 0:00:30
2020-12-11 22:15:00 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.9/site-packages/aiohttp/http_websocket.py", line 673, in ping
    await self._send_frame(message, WSMsgType.PING)
  File "/srv/homeassistant/lib/python3.9/site-packages/aiohttp/http_websocket.py", line 650, in _send_frame
    self._write(header + message)
  File "/srv/homeassistant/lib/python3.9/site-packages/aiohttp/http_websocket.py", line 660, in _write
    raise ConnectionResetError("Cannot write to closing transport")
ConnectionResetError: Cannot write to closing transport
1 Like

I get the same error message. This occurs about once or twice a day. I have no idea where to look or where this error message might come from. Maybe someone here has an idea to find the cause of this error message?


Logger: aiohttp.server
Source: components/websocket_api/http.py:81 
First occurred: 18:33:54 (1 occurrences) 
Last logged: 18:33:54

Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/aiohttp/web_protocol.py", line 422, in _handle_request
    resp = await self._request_handler(request)
  File "/usr/local/lib/python3.8/site-packages/aiohttp/web_app.py", line 499, in _handle
    resp = await handler(request)
  File "/usr/local/lib/python3.8/site-packages/aiohttp/web_middlewares.py", line 118, in impl
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 18, in request_context_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 72, in ban_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 127, in auth_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 129, in handle
    result = await result
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/http.py", line 42, in get
    return await WebSocketHandler(request.app["hass"], request).async_handle()
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/http.py", line 233, in async_handle
    await self._writer_task
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/http.py", line 81, in _writer
    await self.wsock.send_str(message)
  File "/usr/local/lib/python3.8/site-packages/aiohttp/web_ws.py", line 300, in send_str
    await self._writer.send(data, binary=False, compress=compress)
  File "/usr/local/lib/python3.8/site-packages/aiohttp/http_websocket.py", line 687, in send
    await self._send_frame(message, WSMsgType.TEXT, compress)
  File "/usr/local/lib/python3.8/site-packages/aiohttp/http_websocket.py", line 656, in _send_frame
    await self.protocol._drain_helper()
  File "/usr/local/lib/python3.8/site-packages/aiohttp/base_protocol.py", line 87, in _drain_helper
    await waiter
  File "/usr/local/lib/python3.8/asyncio/selector_events.py", line 935, in _write_ready
    n = self._sock.send(self._buffer)
BrokenPipeError: [Errno 32] Broken pipe


Logger: homeassistant
Source: /usr/src/homeassistant/homeassistant/runner.py:99 
First occurred: 18:34:50 (1 occurrences) 
Last logged: 18:34:50

Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/aiohttp/http_websocket.py", line 673, in ping
    await self._send_frame(message, WSMsgType.PING)
  File "/usr/local/lib/python3.8/site-packages/aiohttp/http_websocket.py", line 650, in _send_frame
    self._write(header + message)
  File "/usr/local/lib/python3.8/site-packages/aiohttp/http_websocket.py", line 660, in _write
    raise ConnectionResetError("Cannot write to closing transport")
ConnectionResetError: Cannot write to closing transport

+1
Same for me

I removed the Tuya integration and I don’t have this error anymore… Maybe you Jamie or you Cavekeeper have the same integration installed?

Same error, some solution?