merdok / homebridge-webos-tv

Homebridge plugin for LG webOS TVs
MIT License
663 stars 89 forks source link

Filtering EHOSTDOWN, ETIMEDOUT and ECONNREFUSED. at least EHOSTDOWN. #56

Closed thesquaremedia closed 5 years ago

thesquaremedia commented 6 years ago

I saw the previews issue I would suggest doing something like this below on line 110. Seems like all of this are related to the tv being of. I could create a pr if you let me know which option you prefer.

    this.lgtv.on('error', (error) => {
        if( ! error.contains( 'EHOSTDOWN' ) && ! error.contains( 'ETIMEDOUT' ) && ! error.contains( 'EHOSTDOWN' ) ){
                this.log.error('webOS - %s', error);
        }
    });

or

    this.lgtv.on('error', (error) => {
        if( string.indexOf( 'EHOSTDOWN' ) === -1 && string.indexOf( 'ETIMEDOUT' ) === -1 && string.indexOf( 'ECONNREFUSED' ) === -1 ){
                this.log.error('webOS - %s', error);
        }
    });
merdok commented 6 years ago

I still don't understand why is the error coming so often for some people. In my case it appears very rare, so i am not exactly sure why it is like that. I think this error is related to a network issue and maybe if we filter out this error it might confuse some people who are searching for a reason why the plugin is not working?

thesquaremedia commented 6 years ago

That makes sense I’ll try to see if I can debug it a bit more. When the lgtv turns off and it retira to search for it the message just keeps popping up until tv connects again.

merdok commented 6 years ago

Okay, let me know what you find. I will also try to improve this a little bit.

thesquaremedia commented 6 years ago

@merdok I believe I know why this happens. It has to do with wifi routers using the same SSID for the 2.4 and 5 GHz frequencies. It seems like the tv will randomly disconnect from the network due to this. Giving the 2.4 frequency a different name solves the issue. in fact it makes the plugin work more efficiently. Some wifi routers like att new ones use band steering but as we can see it isn't always effective. Since I made this change I haven't seen the errors show up.

merdok commented 6 years ago

Ok, thanks for the info. So it has something to do with the TV itself. I will try to find maybe a workaround for this but i am not if anything will work since it is clearly a network issue. I leave this issue open till i investigate this.

thesquaremedia commented 6 years ago

@merdok the issue started to popup after I had to restart the router. with this error also showing up webOS - Error: Sec-WebSocket-Accept header from server didn't match expected value of <random- alphanumbericvalue> but I turned on the quick start setting so that the tv stays in stand by and it seems to have resolved it.tv has been off for a few hours and no error logs from tv(never mind stand by mode didn't help). right now I'm wondering if its because the wifi signal deteriorates in my living room causing the tv to drop wifi altogether. looking into a range extender to see if that helps with the problem.

merdok commented 6 years ago

Did you try to connect your TV to LAN to make sure that this is a WiFi only issue?

kapps7 commented 5 years ago

I am seeing this exact issue. Both my TV and home bridge are running on LAN

merdok commented 5 years ago

What issue exactly?

defmech commented 5 years ago

I'm getting the error [TV] webOS - Error: connect EHOSTDOWN multiple times a minute. Homebridge server and TV are on wired LAN connections.

merdok commented 5 years ago

That should be fine as long as there are no issues with the plugin.