home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
73.66k stars 30.8k forks source link

Error doing job: Unclosed client session #13099

Closed sveip closed 6 years ago

sveip commented 6 years ago

Make sure you are running the latest version of Home Assistant before reporting an issue.

You should only file an issue if you found a bug. Feature and enhancement requests should go in the Feature Requests section of our community forum:

Home Assistant release (hass --version): 0.65.0

Python release (python3 --version):

Component/platform:

Description of problem: Problem occurred after upgrade til 0.65.0. The logs are filled with approx 4 of these per minute.

Expected:

Problem-relevant configuration.yaml entries and steps to reproduce:

Traceback (if applicable):

Error doing job: Unclosed client session
8:45 PM core.py (ERROR)
Error doing job: Unclosed client session
8:45 PM core.py (ERROR)
Error doing job: Unclosed client session
8:45 PM core.py (ERROR)
Error doing job: Unclosed client session
8:44 PM core.py (ERROR)
Error doing job: Unclosed client session
8:44 PM core.py (ERROR)
Error doing job: Unclosed client session
8:44 PM core.py (ERROR)
Error doing job: Unclosed client session
8:44 PM core.py (ERROR)
Error doing job: Unclosed client session
8:44 PM core.py (ERROR)
Error doing job: Unclosed client session
8:44 PM core.py (ERROR)
Error doing job: Unclosed client session
8:43 PM core.py (ERROR)
Timer got out of sync. Resetting
8:43 PM core.py (ERROR)
Error doing job: Unclosed client session
8:43 PM core.py (ERROR)
Error doing job: Unclosed client session
8:43 PM core.py (ERROR)
Error doing job: Unclosed client session
8:43 PM core.py (ERROR)
Error doing job: Unclosed client session
8:43 PM core.py (ERROR)
Error doing job: Unclosed client session
8:42 PM core.py (ERROR)
Error doing job: Unclosed client session
8:42 PM core.py (ERROR)
Error doing job: Unclosed client session
8:42 PM core.py (ERROR)
Error doing job: Unclosed client session
8:42 PM core.py (ERROR)
Error doing job: Unclosed client session
8:42 PM core.py (ERROR)
Error doing job: Unclosed client session
8:42 PM core.py (ERROR)
Error doing job: Unclosed client session
8:41 PM core.py (ERROR)
Error doing job: Unclosed client session
8:41 PM core.py (ERROR)
Error doing job: Unclosed client session
8:41 PM core.py (ERROR)
Error doing job: Unclosed client session
8:41 PM core.py (ERROR)
Timer got out of sync. Resetting
8:41 PM core.py (ERROR)
Error doing job: Unclosed client session
8:41 PM core.py (ERROR)
Error doing job: Unclosed client session
8:40 PM core.py (ERROR)
Error doing job: Unclosed client session
8:40 PM core.py (ERROR)
Error doing job: Unclosed client session
8:40 PM core.py (ERROR)
Timer got out of sync. Resetting
8:40 PM core.py (ERROR)
Error doing job: Unclosed client session
8:40 PM core.py (ERROR)
Error doing job: Unclosed client session
8:40 PM core.py (ERROR)
Error doing job: Unclosed client session
8:40 PM core.py (ERROR)
Error doing job: Unclosed client session
8:39 PM core.py (ERROR)
Error doing job: Unclosed client session
8:39 PM core.py (ERROR)
Error doing job: Unclosed client session
8:39 PM core.py (ERROR)
Error doing job: Unclosed client session
8:39 PM core.py (ERROR)
Error doing job: Unclosed client session
8:39 PM core.py (ERROR)
Error doing job: Unclosed client session
8:38 PM core.py (ERROR)
Error doing job: Unclosed client session
8:38 PM core.py (ERROR)
Timer got out of sync. Resetting
8:38 PM core.py (ERROR)
Error doing job: Unclosed client session
8:38 PM core.py (ERROR)
Error doing job: Unclosed client session
8:38 PM core.py (ERROR)
Error doing job: Unclosed client session
8:38 PM core.py (ERROR)
Error doing job: Unclosed client session
8:38 PM core.py (ERROR)

Additional info:

dojf commented 6 years ago

Have the same problem, started after 0.65.0 and still there after 0.65.3.

(Using Hass.io on rpi3, with Xiaomi gateway, sensors, switches and Sonoff mqtt switches ... nothing fancy)

iStehle commented 6 years ago

Same here, still with 0.65.4

Vetti52 commented 6 years ago

I opened the same problem 2d ago there: https://community.home-assistant.io/t/error-doing-job-unclosed-client-session/46796?u=vetti52 So hopefully we get a solution here.....

sveip commented 6 years ago

Same problem in 0.65.5

dojf commented 6 years ago

Same problem in 0.65.6

sveip commented 6 years ago

Same in 66 beta. Any suggestions on how to debug this issue?

dojf commented 6 years ago

As there are over 700 issues in Home Assistant github I'm not sure if our problem get's much attention. What to do? Analyse: It happened after 0.65.0, so has it something to do with change of Python library? Also the generic type of error and the indication "core.py (ERROR)" hints in that direction IMHO. Todos: 1) We could compare our setup's to find out if we have something special in common... 2) We could try to get attention from someone in the core team... 3) We could try to investigate if there are more "core.py" or same sort generic error messages... 4) We could try to change from hass.io to hassbian to see if that helps... 5) We could try to make a minimal setup to see if that helps (uncommenting ## in al yaml files)... My 0,02 €

sveip commented 6 years ago

Agree. What would be the best way to share/compare our config and devices?

dojf commented 6 years ago

Here? My setup: Hass.io running 0.66.b2 (beta) on Pi3. Using Xiaomi/Aqara sensors and switches via a Xiaomi Gateway v2. Also some 7 Sonoff switches via Mosquitto mqtt broker (in Hass.io) and a few Yeelight lamps. Hass.io is also detecting several chromecast devices and I'm using Owntracks for presence detection on two phones.

sveip commented 6 years ago

Sure, but I was more thinking of exporting the entities from hass directly to some github repo or similar so that we can do some diff to see if we have something in common.

dojf commented 6 years ago

Good idea, but takes some time for me to setup and I'm short of time :-(

kulisoft commented 6 years ago

Hi, I experience the same problem since 0.65. yesterday I updated to 0.66 and there is still the problem with „Error doing job: Unclosed client session“ about 3 times a minute. Anybody any idea how to solve that? I am running hass.io on a PI3.

sveip commented 6 years ago

Did some googleing, and the problem seems to originate from iaohttp. There were some changes to that in hass about the same time this warning came, so I suspect it's related.

Changes seen here: https://github.com/home-assistant/home-assistant/commits/89a19c89a768988a35effe4c0463c3a639304a60/homeassistant/helpers/aiohttp_client.py

And some info on the error message: https://github.com/aio-libs/aiohttp/issues/1175

Maybe @balloob can comment?

sveip commented 6 years ago

Sorry to disturb @pvizeli, @fabaff what do you think about the comment above, seems like this bug is related to the iaohttp update. Any chance if looking at it?

teoball commented 6 years ago

still same error in 0.66.1. Filling up the log file...

dojf commented 6 years ago

Also the same in 0.67.0b0.

flodus commented 6 years ago

i think it's a problem with nmap. This problem comes when i do sudo apt-get install net-tools nmap.

230delphi commented 6 years ago

I'm not using nmap.. seeing the same. Ping maybe?

On Sun 15 Apr 2018, 11:03 AM flodus, notifications@github.com wrote:

i think it's a problem with nmap. This problem comes when i do sudo apt-get install net-tools nmap.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/home-assistant/home-assistant/issues/13099#issuecomment-381394545, or mute the thread https://github.com/notifications/unsubscribe-auth/ACyjBQQMZvhvK3C2foS4xZk5p4SU9Ewtks5toxr_gaJpZM4Sl1NK .

sveip commented 6 years ago

I dont see the problem anymore with 0.68. Can anyone confirm it's resolved, so that I can close this issue?

dojf commented 6 years ago

Nope, still there, even in 0.68.1. Didn't see anything changed regarding this error.

sveip commented 6 years ago

Interesting, the only difference I have in my setup is that I no longer have the frontier_silicon media_player. Do you have that one?

On Tue, 1 May 2018, 21:57 dojf, notifications@github.com wrote:

Nope, still there, even in 0.68.1. Didn't see anything changed regarding this error.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/home-assistant/home-assistant/issues/13099#issuecomment-385772290, or mute the thread https://github.com/notifications/unsubscribe-auth/AFceL76OAt0-_zrJm_nHsbHRO123NQK3ks5tuL43gaJpZM4Sl1NK .

dojf commented 6 years ago

Yes, I have a Sangean WFR-27C internet Radio which is autodetected. And it uses frontier_silicon media_player.

I will block it and see what happens.

dojf commented 6 years ago

Aarrgg, in our setups the frontier_silicon was the delinquent!

I changed the discovery in configuration.yaml `discovery: ignore:

Great, you found it Sveip, thanks!

230delphi commented 6 years ago

same here - ignore: -frontier_silicon removes the problem... now how do we get this bug report moved to that component?

sveip commented 6 years ago

@zhelev might know, he recently refactored the component to async. Issue here: https://github.com/home-assistant/home-assistant/issues/11853

Maybe the mix of new frontier_silicon and iaohttp is the cause?

CristianPopescu commented 6 years ago

Hello,

I had the same problem and my Frontier Silicon based speaker was not working anymore. The minuet based speakers were not working with the home assistant, but the old Venice based speakers were working.

Long story short, you don't need a new session in fsapi each time that Homeassistant queries the speaker for data. All I did was to modify the fsapi package, remove the sid creation and worked fine. You need to locate the following file:

/srv/homeassistant/lib/python3.5/site-packages/afsapi/init.py

And modify the call function (starting with line 88). This is how my function looks right now:

` def call(self, path, extra=None):

    """Execute a frontier silicon API call."""
    try:
        self.__webfsapi = yield from self.get_fsapi_endpoint()
        if not isinstance(extra, dict):
            extra = dict()
        params = dict(pin=self.pin)
        params.update(**extra)
        req_url = ('%s/%s' % (self.__webfsapi, path))
        result = yield from self.__session.get(req_url, params=params, timeout = self.timeout)
        if result.status == 200:
            text = yield from result.text(encoding='utf-8')
        else:
            self.sid = yield from self.create_session()
            params = dict(pin=self.pin, sid=self.sid)
            params.update(**extra)
            result = yield from self.__session.get(req_url, params=params,
                                                   timeout = self.timeout)
            text = yield from result.text(encoding='utf-8')

        return objectify.fromstring(text)
    except Exception as e:
        logging.info('AFSAPI Exception: ' +traceback.format_exc())

    return None`
johnjones commented 6 years ago

This is directly because of the Frontier silicon API call however the above is not ideal @zhelev @fabaff

qrioniclabs commented 6 years ago

I am getting the same errors:

Jun 21 18:19:53 [hostname] hass[14187]: /home/user/homeassistant/lib/python3.6/site-packages/afsapi/__init__.py:65: RuntimeWarning: coroutine 'ClientSession.close' was never awaited
Jun 21 18:19:53 [hostname] hass[14187]:   self.__session.close()
Jun 21 18:19:53 [hostname] hass[14187]: 2018-06-21 18:19:53 ERROR (MainThread) [homeassistant.core] Error doing job: Unclosed client session
Jun 21 18:19:53 [hostname] hass[14187]: 2018-06-21 18:19:53 ERROR (MainThread) [homeassistant.core] Error doing job: Unclosed client session

No Frontier Silicon device in the network (I have a radio, but it is not connected).

I have

discovery:
  ignore:
    - frontier_silicon

in configuration.yaml.

Python 3.6.3, Home Assistant 0.71.0

sveip commented 6 years ago

Any progress on this issue?

G33kM0bile commented 6 years ago

Still same issue, running v 0.75.1 on hass.io, getting about 5 errors very minute

zhelev commented 6 years ago

I will have a look at the issue this week and will try to do a pull request before Saturday. I am in the process of moving to a different place and my device lies somewhere in a box in the basement.

markspolakovs commented 6 years ago

@zhelev any news? (no worries if the answer is no)