core: Google cast floods logs with errors when Chromecast device is powered off.

The problem

Since probably release 2022.4.5 log of my HA is getting flooded with error messages from google cast integration upon powering off TV (which supplies power to Chromecast). There are thousands of error messages logged overnight and they all look the same:

2022-04-22 05:02:03 ERROR (Thread-16) [pychromecast.socket_client] [Salon(10.144.1.138):8009] Error in select call: filedescriptor out of range in select()
2022-04-22 05:02:03 ERROR (Thread-17) [pychromecast.socket_client] [Salon(10.144.1.138):32229] Error in select call: filedescriptor out of range in select()

Interestingly the errors stop the moment the TV gets power in the morning, although Chromecast device stays unavailable as the TV is still off (maybe it is powered on for a while after turning on the smart plug providing power to the TV)

What version of Home Assistant Core has the issue?

core-2022.4.6

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant Core

Integration causing the issue

Google Cast

Link to integration documentation on our website

https://www.home-assistant.io/integrations/cast/

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

2022-04-22 05:02:03 ERROR (Thread-16) [pychromecast.socket_client] [Salon(10.144.1.138):8009] Error in select call: filedescriptor out of range in select()
2022-04-22 05:02:03 ERROR (Thread-17) [pychromecast.socket_client] [Salon(10.144.1.138):32229] Error in select call: filedescriptor out of range in select()

Additional information

No response

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 1
  • Comments: 20 (7 by maintainers)

Most upvoted comments

OK, done, will post back tomorrow.

Please turn on debug logging and share a log where the problem is reproduced

logger:         
  default: info 
  logs:         
    homeassistant.components.cast: debug             
    homeassistant.components.cast.media_player: debug
    pychromecast: debug                              
    pychromecast.dial: debug                         
    pychromecast.discovery: info                     
    pychromecast.controllers.media: debug            
    pychromecast.socket_client: debug                
    homeassistant.components.zeroconf: debug         
    zeroconf: info                                   

@adorobis FreeBSD is not a supported setup. It may very well be that its socket implementation behaves differently, tripping up pychromecast somehow.

Interesting that you don’t see the problem when downgrading pychromecast; there are no intentional changes to the way it handles sockets in versions 11.0.0 or 12.0.0.

Based on the error message I suspect there’s either a socket leak, meaning the system is out of sockets and pychromecast sometimes can’t open a new one when trying to reconnect, or the error returned when trying to connect to the turned off chromecast is not what pychromecast expects so it goes ahead trying to use an invalid socket.

It’s probably easier to tinker with pychromecast by itself than the full Home Assistant setup, at least if the problem is easy to reproduce.

pychromecast has an example script which you can start like this: python3 examples/simple_listener_example.py --cast=<name of your cast>, it simply connects to the chromecast and waits for things to happen, in pretty much the same way as home assistant does. Maybe you could try running that from within the homeassistant venv, both with version 10.3.0 and the version where you saw the problem? You can pass it the flag --show-debug to enable debug log.