plasticrake / homebridge-tplink-smarthome

TP-Link Smarthome Plugin for Homebridge
MIT License
474 stars 70 forks source link

Constant TCP Timeout Errors #88

Closed 400HPMustang closed 2 years ago

400HPMustang commented 5 years ago

Expected Behavior

Lights should respond fairly quickly to home kit, turn off and on when triggered

Current Behavior

Lights are sluggish, slow to respond and/or just unresponsive all together

Steps to Reproduce (for bugs)

Add HS100 plugs or LB100 bulbs to Homebridge?

Versions

Configuration

{
            "platform": "TplinkSmarthome",
            "name": "TplinkSmarthome"
        },

Homebridge Log / Command Output

[8/12/2019, 7:11:23 AM] [Config] Console v4.5.2 is listening on :: port 8008
[8/12/2019, 7:12:54 AM] [TplinkSmarthome.API] TCP Timeout
[8/12/2019, 7:12:54 AM] [TplinkSmarthome.API] TCP Timeout
[8/12/2019, 7:12:54 AM] [TplinkSmarthome.API] [Garage Door Left] device.send() Error: TCP Timeout
[8/12/2019, 7:12:54 AM] [TplinkSmarthome.API] [Garage Door Left] device.send() Error: TCP Timeout
[8/12/2019, 7:12:54 AM] [TplinkSmarthome] [Garage Door Left]
[8/12/2019, 7:12:54 AM] [TplinkSmarthome] Error: TCP Timeout
    at Timeout.setTimeout [as _onTimeout] (C:\Users\Admin\AppData\Roaming\npm\node_modules\homebridge-tplink-smarthome\node_modules\tplink-smarthome-api\lib\client.js:228:20)
    at ontimeout (timers.js:436:11)
    at tryOnTimeout (timers.js:300:5)
    at listOnTimeout (timers.js:263:5)
    at Timer.processTimers (timers.js:223:10)
[8/12/2019, 7:12:54 AM] [TplinkSmarthome] [Garage Door Left]
[8/12/2019, 7:12:54 AM] [TplinkSmarthome] Error: TCP Timeout
    at Timeout.setTimeout [as _onTimeout] (C:\Users\Admin\AppData\Roaming\npm\node_modules\homebridge-tplink-smarthome\node_modules\tplink-smarthome-api\lib\client.js:228:20)
    at ontimeout (timers.js:436:11)
    at tryOnTimeout (timers.js:300:5)
    at listOnTimeout (timers.js:263:5)
    at Timer.processTimers (timers.js:223:10)
[8/12/2019, 7:15:01 AM] [TplinkSmarthome.API] TCP Timeout
[8/12/2019, 7:15:01 AM] [TplinkSmarthome.API] TCP Timeout
[8/12/2019, 7:15:01 AM] [TplinkSmarthome.API] [Garage Door Left] device.send() Error: TCP Timeout
[8/12/2019, 7:15:01 AM] [TplinkSmarthome.API] [Garage Door Left] device.send() Error: TCP Timeout
[8/12/2019, 7:15:01 AM] [TplinkSmarthome] [Garage Door Left]
[8/12/2019, 7:15:01 AM] [TplinkSmarthome] Error: TCP Timeout
    at Timeout.setTimeout [as _onTimeout] (C:\Users\Admin\AppData\Roaming\npm\node_modules\homebridge-tplink-smarthome\node_modules\tplink-smarthome-api\lib\client.js:228:20)
    at ontimeout (timers.js:436:11)
    at tryOnTimeout (timers.js:300:5)
    at listOnTimeout (timers.js:263:5)
    at Timer.processTimers (timers.js:223:10)
[8/12/2019, 7:15:01 AM] [TplinkSmarthome] [Garage Door Left]
[8/12/2019, 7:15:01 AM] [TplinkSmarthome] Error: TCP Timeout
    at Timeout.setTimeout [as _onTimeout] (C:\Users\Admin\AppData\Roaming\npm\node_modules\homebridge-tplink-smarthome\node_modules\tplink-smarthome-api\lib\client.js:228:20)
    at ontimeout (timers.js:436:11)
    at tryOnTimeout (timers.js:300:5)
    at listOnTimeout (timers.js:263:5)
    at Timer.processTimers (timers.js:223:10)
kwalkington commented 4 years ago

I'm getting the same thing.

Calprainn commented 4 years ago

Same here. Config runs two/three in row without any issues. Since yesterday I'm getting also TCP timeouts. Ironically just for one of my four HS100 plugs. I don't get it. 🤷🏻‍♀️

kwalkington commented 4 years ago

Any update about this? I deleted the plugin as it was unusable.

400HPMustang commented 4 years ago

I haven't had any more instances of the timeouts in my logs that I've seen BUT since I posted this I've removed all but one TP-Link device from my home. I just have one plug left over in my setup.

Wiejeben commented 4 years ago

Looks like this is obviously coming from https://github.com/plasticrake/tplink-smarthome-api. Someone already made a pull request with a potential fix, lets hope this solves the turning off and on again of your TP-Link accessories.

https://github.com/plasticrake/tplink-smarthome-api/pull/95

anubisvic commented 4 years ago

Also suffering from this issue, really hope what the pull request @Wiejeben mentioned would fix this issue. For my situation, it only occurs to one of my switches that could be in a wifi dead zone.

aanon4 commented 4 years ago

I've been kicking this problem around for a few days after I added an HS300 and everything started timing out. Looking though the debugging (which is mostly in the -api library) I see socket.connect calls being made but the callback never happens because, I assume, the connection is never completed by the HS300. It seems to happen when there's a lot of activity, so perhaps the tplink devices can only handle so many incoming connections at a time, and drop other on the floor if there's too many? I'm testing a hack in a copy of the code currently so see if forcing a one-at-a-time queue when calling devices improves reliability.

aanon4 commented 4 years ago

Another observation here is that the discovery timer is 10 seconds by default, but the connection timeout is 15 seconds; so when TCP starts acting up on a device, the discovery pings starts up more and more TCP connections because each discovery cycle generates an emeter update per plug (not sure why that code is there, but it is) and these can get stuck timing out. On the HS300 (what I have) this generates 6 sets of calls, one for each plug on the strip. This doesnt seem to be helping things recover. So maybe bumping the pollingInterval to something like 60 seconds might help things.

DrFunkelstein commented 3 years ago

I wanted to add that I'm having the same problem. Can't seem to identify what leads up to the errors. I only have 2 total devices (both smart outlets) and am only having this problem with one of them.

kennenlaw5 commented 3 years ago

Going to comment to bump this issue. Seems directly related to the HS300’s on my system. My activity log is littered with these errors. As of right now, I have determined that these errors eventually amass to a point where hoobs actually crashes and everything has to reboot. Has anyone figured anything out as to how to reduce these errors?

400HPMustang commented 2 years ago

Going to close this out since I don't have any TPLink devices on my network anymore.