ualex73 / monitor_docker

Monitor Docker containers from Home Assistant
Apache License 2.0
267 stars 34 forks source link

Unclosed client session #146

Closed FuzzyMistborn closed 1 month ago

FuzzyMistborn commented 1 month ago

Was noticing my logs were getting filled with lots of ERROR (Recorder) [homeassistant] Error doing job: Unclosed client session in my log (a thousand or so entries a day)

Added debugpy: to my config, and this now is coming up:

2024-05-10 11:17:42.698 ERROR (Recorder) [homeassistant] Error doing job: Unclosed client session: File "<frozen runpy>", line 198, in _run_module_as_main
File "<frozen runpy>", line 88, in _run_code
File "/usr/src/homeassistant/homeassistant/__main__.py", line 220, in <module>
sys.exit(main())
File "/usr/src/homeassistant/homeassistant/__main__.py", line 208, in main
exit_code = runner.run(runtime_conf)
File "/usr/src/homeassistant/homeassistant/runner.py", line 190, in run
return loop.run_until_complete(setup_and_run_hass(runtime_config))
File "/usr/local/lib/python3.12/asyncio/base_events.py", line 672, in run_until_complete
self.run_forever()
File "/usr/local/lib/python3.12/asyncio/base_events.py", line 639, in run_forever
self._run_once()
File "/usr/local/lib/python3.12/asyncio/base_events.py", line 1980, in _run_once
handle._run()
File "/usr/local/lib/python3.12/asyncio/events.py", line 88, in _run
self._context.run(self._callback, *self._args)
File "/config/custom_components/monitor_docker/__init__.py", line 107, in RunDocker
await hass.data[DOMAIN][entry[CONF_NAME]][API].init(startCount)
File "/config/custom_components/monitor_docker/helpers.py", line 162, in init
self._api = aiodocker.Docker(url=url)
File "/usr/local/lib/python3.12/site-packages/aiodocker/docker.py", line 133, in __init__
session = aiohttp.ClientSession(connector=self.connector)
ualex73 commented 1 month ago

How is your connection setup to docker? file? tcp? etc?

FuzzyMistborn commented 1 month ago

Some over file, but most are over TCP.

ualex73 commented 1 month ago

Can you make a tcpdump and share? I assume you do not use an encrypted connection.

FuzzyMistborn commented 1 month ago

No, I use SSL/TLS with this: https://github.com/kekru/docker-remote-api-tls

ualex73 commented 1 month ago

Ok, you got a proxy between HA and Docker instance. Can you test it without the proxy? So directly connecting to the Docker instance?

FuzzyMistborn commented 1 month ago

I switched to tecnativa/docker-socket-proxy as suggested in the readme (been a while since I looked them over) and am running a test with the HA host and a remote host. So far no errors after about 20 minutes of uptime.

FuzzyMistborn commented 1 month ago

Ok, not sure if it was the proxy container I was using, TLS issues, or that there was an old container in my containers section for the HA config that no longer exists, but I haven't seen an error in a few hours since switching to the new proxy container. So going to close. Thanks for the help!

ualex73 commented 1 month ago

Possible it is a nginx setting in that proxy, I found this information https://serverfault.com/questions/777749/how-to-disable-timeout-for-nginx/993559#993559