I recently changed from https to http in preparation to move to a proxy. Everything is working well except I see a ton of these in the log:
Traceback (most recent call last):
File "/usr/local/lib/python3.9/site-packages/aiohttp/web_protocol.py", line 334, in data_received
messages, upgraded, tail = self._request_parser.feed_data(data)
File "aiohttp/_http_parser.pyx", line 551, in aiohttp._http_parser.HttpParser.feed_data
aiohttp.http_exceptions.BadStatusLine: 400, message="Bad status line 'Invalid method encountered'"
2022-01-25 20:57:58 ERROR (MainThread) [aiohttp.server] Error handling request
I know that this relates to something hitting the old https based URL which is no longer available. However, I am struggling to figure out how to find the rogue process/client that is doing this. This brings a few questions:
Is there any way to up debugging to get any information about the offending client or process?
Could this be an existing integration or add-on causing this?
Is there anywhere else I should look for offending configuration parameters?
Near term I have solved this problem by reducing aiohttp log levels, but that seems like a band aid.
I never heard a response on this post. However, I ended up solving the problem by using logs. The problem related to a script that was running on one host that kept hitting the old https address. Once I found it, it was simple to make the change, and the problems went away.
Unfortunately, the analysis was manual on my part.
Similar problem here, but I know it’s related to NGINX. I was using DuckDNS and it was all working. I tried both the NGINX HA Assistant Proxy and the NGINX Proxy Manager add-ons and they don’t work, giving me this error in the logs. I tried re-installing the add-ons too. The add-ons themselves seems to work, but they don’t serve HTTPS as expected. Error paste:
2022-03-03 07:39:38 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
File "/usr/local/lib/python3.9/site-packages/aiohttp/web_protocol.py", line 334, in data_received
messages, upgraded, tail = self._request_parser.feed_data(data)
File "aiohttp/_http_parser.pyx", line 551, in aiohttp._http_parser.HttpParser.feed_data
aiohttp.http_exceptions.BadStatusLine: 400, message="Bad status line 'Invalid method encountered'"
2022-03-03 07:39:38 ERROR (MainThread) [aiohttp.server] Error handling request
If I re-enable this in my configuration.yaml file, the errors disappear from the log and I get the SSL cert without issues:
Changed the trusted proxies combination, tried 192.168.1.0/24 and I even tried 0.0.0.0/0; same results. The logs gets exactly 14 errors as above every time I try to access the site using HTTPS. The certificate does not get transferred either.
I’m really at lost here. Nothing I tried worked. Could this be related: aio-libs/aiohttp#6566 ?
I think I will just bite the bullet and try a complete fresh install… But I may end up with the same situation.
This is a different issue, but I recently setup a reverse proxy too. I configured HA to run http locally and Apache to serve https via the reverse proxy.
The other setting that I noticed in your post that could be different is “trusted_proxy”. For me, Apache is running a different system and so I configured trusted_proxies just to contain the Apache IP address. I did not even use a CIDR. e.g. this:
It may not help anyone, but after a lot of trial and error for me the source of the aiohttpserver 400 message was NodeRed. After defining the new HASS adress AND rebooting the nodered container all was fine again.
Thank you! I’ve been chasing this for several days. The difference was rebooting the nodered instance. Just changing the HA node in nodered didn’t do it
2023-09-06 23:06:16.658 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
File "/usr/local/lib/python3.11/site-packages/aiohttp/web_protocol.py", line 332, in data_received
messages, upgraded, tail = self._request_parser.feed_data(data)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "aiohttp/_http_parser.pyx", line 557, in aiohttp._http_parser.HttpParser.feed_data
aiohttp.http_exceptions.BadStatusLine: 400, message:
Bad status line "Invalid method encountered:\n\n b'\\x16\\x03\\x01\\x01T\\x01'\n ^"
Setup caddy Reverse Proxy for Home Assistant and change HA from HTTPS back to HTTP. Forget to change HA Base URL in Node Red from HTTPS to HTTP. After changing deploying changes in Node Red and Conatainer restart, the issue is gone.
So the issue was Node Red trying to Connect to HA via HTTPS, while HA was (re-) configured for HTTP.
If HA is configured for HTTP, make sure everything is connecting to HA via HTTP (like Revers Proxy, Node Red, Scripts, Services, etc.)
This appears in my log roughly twice a minute. Reading this thread, am I right that this is about an incoming HTTP request? I have no idea what that could be… Is there any way to make that aiohttp thing be more verbose in the logging, and e.g. log some headers or maybe the originating IP address? That would be very helpful for identifying the source of the requests.