core: AttributeError: 'NoneType' object has no attribute 'resume_reading'

The problem

I am getting a lot of errors related to aiohttp.server.

Environment

  • Home Assistant Core release with the issue: core-2021.1.5
  • Last working Home Assistant Core release (if known): -
  • Operating environment (OS/Container/Supervised/Core): OS in Proxmox VM
  • Integration causing this issue:
  • Link to integration documentation on our website:

Problem-relevant configuration.yaml


Traceback/Error logs

Logger: aiohttp.server
Source: /usr/local/lib/python3.8/site-packages/aiohttp/web_protocol.py:393
First occurred: 11:02:05 (3 occurrences)
Last logged: 11:02:05
Unhandled exception

Traceback (most recent call last):
  File "/usr/local/lib/python3.8/asyncio/base_events.py", line 1152, in _sendfile_fallback
    read = await self.run_in_executor(None, file.readinto, view)
asyncio.exceptions.CancelledError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/aiohttp/web_protocol.py", line 485, in start
    resp, reset = await task
  File "/usr/local/lib/python3.8/site-packages/aiohttp/web_protocol.py", line 440, in _handle_request
    reset = await self.finish_response(request, resp, start_time)
  File "/usr/local/lib/python3.8/site-packages/aiohttp/web_protocol.py", line 591, in finish_response
    await prepare_meth(request)
  File "/usr/local/lib/python3.8/site-packages/aiohttp/web_fileresponse.py", line 241, in prepare
    return await self._sendfile(request, fobj, offset, count)
  File "/usr/local/lib/python3.8/site-packages/aiohttp/web_fileresponse.py", line 96, in _sendfile
    await loop.sendfile(transport, fobj, offset, count)
  File "/usr/local/lib/python3.8/asyncio/base_events.py", line 1131, in sendfile
    return await self._sendfile_fallback(transport, file,
  File "/usr/local/lib/python3.8/asyncio/base_events.py", line 1161, in _sendfile_fallback
    await proto.restore()
  File "/usr/local/lib/python3.8/asyncio/base_events.py", line 263, in restore
    self._transport.resume_reading()
  File "/usr/local/lib/python3.8/asyncio/sslproto.py", line 344, in resume_reading
    self._ssl_protocol._transport.resume_reading()
AttributeError: 'NoneType' object has no attribute 'resume_reading'

Additional information

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 27
  • Comments: 46 (7 by maintainers)

Most upvoted comments

I had this error after a recent update. The main problem was http.base_url. It is not supported anymore. So I removed it from the config. I had to add homeassistant.external_url and tts.base_url. Then I got this error. Adding homeassistant.internal_url fixed it.

homeassistant:
  internal_url: https://192.168.1.20:4312
  external_url: https://myac.duckdns.org:4312

tts:
  - platform: google_translate
    service_name: google_say
    base_url: https://myac.duckdns.org:4312

Make sure there is no slash / at the end of URLs.

Same problem here, anybody found a solution for this? I can’t access from my duckdns url. only with the internal IP address.

2021-03-25 09:44:49 ERROR (MainThread) [aiohttp.server] Unhandled exception Traceback (most recent call last): File “/usr/local/lib/python3.8/asyncio/base_events.py”, line 1152, in _sendfile_fallback read = await self.run_in_executor(None, file.readinto, view) asyncio.exceptions.CancelledError

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File “/usr/local/lib/python3.8/site-packages/aiohttp/web_protocol.py”, line 485, in start resp, reset = await task File “/usr/local/lib/python3.8/site-packages/aiohttp/web_protocol.py”, line 440, in _handle_request reset = await self.finish_response(request, resp, start_time) File “/usr/local/lib/python3.8/site-packages/aiohttp/web_protocol.py”, line 591, in finish_response await prepare_meth(request) File “/usr/local/lib/python3.8/site-packages/aiohttp/web_fileresponse.py”, line 241, in prepare return await self._sendfile(request, fobj, offset, count) File “/usr/local/lib/python3.8/site-packages/aiohttp/web_fileresponse.py”, line 96, in _sendfile await loop.sendfile(transport, fobj, offset, count) File “/usr/local/lib/python3.8/asyncio/base_events.py”, line 1131, in sendfile return await self._sendfile_fallback(transport, file, File “/usr/local/lib/python3.8/asyncio/base_events.py”, line 1161, in _sendfile_fallback await proto.restore() File “/usr/local/lib/python3.8/asyncio/base_events.py”, line 263, in restore self._transport.resume_reading() File “/usr/local/lib/python3.8/asyncio/sslproto.py”, line 344, in resume_reading self._ssl_protocol._transport.resume_reading() AttributeError: ‘NoneType’ object has no attribute ‘resume_reading’

In my case, it was a problem with the service provider, it change me to CGNAT without permission or any advice, and all the packets does not have answer. After some calls and back to no CGNAT all works again. It seems it was a problem of communications, check gateways, firewalls, proxies, etc.

Dani.

I have the same issue as well, and did some tests to figure out when it happens. I am also running the latest core-2021.1.5 in Proxmox VM, with Home Assistant OS.

This error only occurs when I enable HTTPS, which I do by adding ssl_certificate and ssl_key parameters to the config file. I generate my own certs and keys using my own CA. If I revert to HTTP, this error does not appear in the log. My HTTPS setup is internal-only and I have my HTTPS address setup in the “internal url” box in the settings.

http:
    ssl_certificate: /config/certs/homeassistant.crt
    ssl_key: /config/certs/homeassistant.key

In addition, to get the error to pop up, one has to enable HTTPS, restart the HA instance (to load the config), and access the HA Web GUI using HTTPS in a browser. The error appears in the log several times when the login page appears in your browser.

After I enter my login and press “next”, the page refreshes automatically, requiring me to login again! There are no additional error messages on the second login, and I can enter the HA Web GUI using HTTPS. The errors and double login issue appear consistently every time I login to HA, with cookies and cache cleared.

Further checking reveals that I only have to login twice with Chromium (Linux). Firefox (Linux) also triggers the error code, but I only have to enter my credentials once before I get sent to the dashboard. Both browser tests were done on a clean profile with stock configuration. Otherwise, the Web GUI works normally with HTTPS enabled.

(Referencing the above strikethrough text)… Actually the double refresh issue is due to the fact that the Web GUI opens slowly, after the login page loads you have to wait a bit (around 10s on my end) before it automatically refreshes once. If you login before it automatically refreshes, then it kicks you back to login again. If you login after, it logs in fine. This is exactly like what this guy reported on the HA forum.

The full error message is below, this is identical to OP’s post.

2021-02-02 13:42:49 ERROR (MainThread) [aiohttp.server] Unhandled exception
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/asyncio/base_events.py", line 1152, in _sendfile_fallback
    read = await self.run_in_executor(None, file.readinto, view)
asyncio.exceptions.CancelledError
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/aiohttp/web_protocol.py", line 485, in start
    resp, reset = await task
  File "/usr/local/lib/python3.8/site-packages/aiohttp/web_protocol.py", line 440, in _handle_request
    reset = await self.finish_response(request, resp, start_time)
  File "/usr/local/lib/python3.8/site-packages/aiohttp/web_protocol.py", line 591, in finish_response
    await prepare_meth(request)
  File "/usr/local/lib/python3.8/site-packages/aiohttp/web_fileresponse.py", line 241, in prepare
    return await self._sendfile(request, fobj, offset, count)
  File "/usr/local/lib/python3.8/site-packages/aiohttp/web_fileresponse.py", line 96, in _sendfile
    await loop.sendfile(transport, fobj, offset, count)
  File "/usr/local/lib/python3.8/asyncio/base_events.py", line 1131, in sendfile
    return await self._sendfile_fallback(transport, file,
  File "/usr/local/lib/python3.8/asyncio/base_events.py", line 1161, in _sendfile_fallback
    await proto.restore()
  File "/usr/local/lib/python3.8/asyncio/base_events.py", line 263, in restore
    self._transport.resume_reading()
  File "/usr/local/lib/python3.8/asyncio/sslproto.py", line 344, in resume_reading
    self._ssl_protocol._transport.resume_reading()
AttributeError: 'NoneType' object has no attribute 'resume_reading'
2021-02-02 13:42:49 ERROR (MainThread) [aiohttp.server] Unhandled exception
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/asyncio/base_events.py", line 1152, in _sendfile_fallback
    read = await self.run_in_executor(None, file.readinto, view)
asyncio.exceptions.CancelledError
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/aiohttp/web_protocol.py", line 485, in start
    resp, reset = await task
  File "/usr/local/lib/python3.8/site-packages/aiohttp/web_protocol.py", line 440, in _handle_request
    reset = await self.finish_response(request, resp, start_time)
  File "/usr/local/lib/python3.8/site-packages/aiohttp/web_protocol.py", line 591, in finish_response
    await prepare_meth(request)
  File "/usr/local/lib/python3.8/site-packages/aiohttp/web_fileresponse.py", line 241, in prepare
    return await self._sendfile(request, fobj, offset, count)
  File "/usr/local/lib/python3.8/site-packages/aiohttp/web_fileresponse.py", line 96, in _sendfile
    await loop.sendfile(transport, fobj, offset, count)
  File "/usr/local/lib/python3.8/asyncio/base_events.py", line 1131, in sendfile
    return await self._sendfile_fallback(transport, file,
  File "/usr/local/lib/python3.8/asyncio/base_events.py", line 1161, in _sendfile_fallback
    await proto.restore()
  File "/usr/local/lib/python3.8/asyncio/base_events.py", line 263, in restore
    self._transport.resume_reading()
  File "/usr/local/lib/python3.8/asyncio/sslproto.py", line 344, in resume_reading
    self._ssl_protocol._transport.resume_reading()
AttributeError: 'NoneType' object has no attribute 'resume_reading'