plasticrake / homebridge-tplink-smarthome

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

TCP Socket Closed error #134

Open a-dows opened 4 years ago

a-dows commented 4 years ago

Getting continuous errors:

Error: TCP Socket Closed. segment:0 hadError:false at Socket. (/usr/local/lib/node_modules/homebridge-tplink-smarthome/node_modules/tplink-smarthome-api/lib/network/tcp-socket.js:113:19) at Object.onceWrapper (events.js:422:26) at Socket.emit (events.js:315:20) at TCP. (net.js:674:12)

All my devices are online.

It appears this issue is causing my other homebridge devices to appear unresponsive.

larcin78 commented 4 years ago

I am seeing this issue as well. They error and then all accessories in Homebridge are borked until I bounce the service.

loaxley commented 4 years ago

Also having this issue repeatedly

xrvk commented 4 years ago

Also seeing this issue and have to restart the service after roughly 24h. I'm noticing that most of the errors are coming from the HS300 (smart power strip) and think that it may have to do with the energy monitoring feature.

a-dows commented 4 years ago

@xrvk i noticed your edit—did the downgrade not fix it? I also think it's the HS300 I have.

xrvk commented 4 years ago

It crashed pretty much right after I posted the comment unfortunately. I think another workaround might be to unplug + replug the power from the HS300. It seems to reduce the number of errors afterwards which lets homebridge's uptime go longer.

loaxley commented 4 years ago

I also have a HS300 power strip, so it seems like we've isolated the issue to that device. @a-dows do you know if there's any way to disable the energy monitoring feature?

a-dows commented 4 years ago

In the plugin, yes, but it doesn't have an effect.

image
xrvk commented 4 years ago

Just to note, I have already configured in the config file to turn off this flag energy monitoring a long time ago but this issue is still happening.

"addCustomCharacteristics": false

Also this is related to issue #44 for those following the thread.

z571 commented 4 years ago

Similarly running into TCP issues, but with HS103 plugs, specifically with homebridge. I'm otherwise able to search for and interact on other machines on the same network.

https://github.com/plasticrake/tplink-smarthome-api/issues/105

a-dows commented 4 years ago

Hope someone can figure out a workaround (or an alternative plugin!). Totally breaks functionality.

larcin78 commented 4 years ago

I am also having the same issue with my HS300s only so far. All 3 give the same TCP timeout error since I update the plugin to v5.1.0. it was rock solid before the update to v5.1.0.

songo-github commented 4 years ago

https://github.com/plasticrake/homebridge-tplink-smarthome/issues/131#issuecomment-662983847

For anyone who finds this, here's the solution thats worked for for some.

plasticrake commented 4 years ago

I've released v5.2.0 which should fix this issue. @a-dows please let me know if this resolved the issue for you!

ratsoid commented 4 years ago

Same issue:

192.168.100.103:9999 {"system":{"get_sysinfo":{}}} at Timeout._onTimeout (/usr/local/lib/node_modules/homebridge-tplink-smarthome/node_modules/tplink-smarthome-api/lib/network/tcp-socket.js:59:36) at listOnTimeout (internal/timers.js:531:17) at processTimers (internal/timers.js:475:7)

twebster22 commented 4 years ago

I was experiencing the same issue as well. I blocked the MAC address for my HS300 and now everything is working. But it is a bummer that I can't use my HS300 with Homekit

jnooraga commented 4 years ago

I'm seeing this error with a KP400 plug unit. Interestingly, it will receive commands intermittently, but it almost always throws: [Tplink.API] [Plug1] device.send() Error: TCP Socket Closed. segment:0 hadError:false at Socket. (/usr/local/lib/node_modules/homebridge-tplink-smarthome/node_modules/tplink-smarthome-api/src/network/tcp-socket.ts:128:19) at Object.onceWrapper (events.js:422:26) at Socket.emit (events.js:315:20) at TCP. (net.js:673:12)

jdebner commented 4 years ago

I'm also running into this on the latest version V6.1. I've tried turning off the power meter characteristic. I do have an HS300 on my network.

Anything else I should try or something that would be helpful to debug?

Error: TCP Timeout after 15000ms 192.168.1.193:9999 {"emeter":{"get_realtime":{}},"context":{"child_ids":["80065EC819994B9E6B7025B3102DF5AA1D59C67400"]}} at Timeout._onTimeout (/usr/local/lib/node_modules/homebridge-tplink-smarthome/node_modules/tplink-smarthome-api/src/network/tcp-socket.ts:67:17) at listOnTimeout (internal/timers.js:554:17) at processTimers (internal/timers.js:497:7)

cjsfj commented 3 years ago

I get this too, with the most recent version of this plugin (6.1.0). I also have an HS300.

[12/13/2020, 2:02:46 PM] [TplinkSmarthome.API] TCP 192.168.2.190:9999 Error: TCP Socket Closed. segment:0 hadError:false
    at Socket.<anonymous> (/opt/local/lib/node_modules/homebridge-tplink-smarthome/node_modules/tplink-smarthome-api/src/network/tcp-socket.ts:128:19)
    at Object.onceWrapper (events.js:422:26)
    at Socket.emit (events.js:315:20)
    at TCP.<anonymous> (net.js:673:12)

My Homebridge server info:

For a few weeks, I would notice the socket error only when my outlets would show unresponsive in the home app. After looking more closely, I'd find that the socket error would happen about two hours after I would restart the Homebridge service.

Two days ago, I disabled the energy option for this plugin. I also updated the global homebridge config to specify a single mdns IP address.

Since then, I'm still getting socket errors in the log, but the outlets have continued to function as expected in the home app.

Definitely crashing about once per day. Only fixable by restarting homebridge.

thevaibhav commented 3 years ago

Using a Pi 3 b, OS image from Homebridge. Node.js version is v14.15.1.. Homebridge V1.1.6, TP link Plugin is v6.1.0

Have tried this on the hoobs image as well.. Have 7 HS300 strips that error out and make the homebridge non responsive.

My config is { "name": "Kasa Homebridge", "addCustomCharacteristics": false, "deviceTypes": [ "plug", "bulb" ], "platform": "TplinkSmarthome" }

Below is the details of the error

16/12/2020, 12:17:19] [Kasa Homebridge] [Master Plug 7] emeter.getRealtime()

[16/12/2020, 12:17:19] [Kasa Homebridge] Error: TCP Socket Closed. segment:0 hadError:false at Socket. (/usr/local/lib/node_modules/homebridge-tplink-smarthome/node_modules/tplink-smarthome-api/src/network/tcp-socket.ts:128:19) at Object.onceWrapper (events.js:422:26) at Socket.emit (events.js:315:20) at TCP. (net.js:673:12)

jdebner commented 3 years ago

I ended up just looking up the MAC address of the HS300 and blocking it in the plug in settings as suggested by another poster here. That has solved my time out issue but of course I'm now unable to control the HS300 outlet from homekit.

dcanderson1960 commented 3 years ago

I am seeing this also on Raspberry Pi HomeKit. 6.1.0 of the Plug In. HS300 plug is the issue. I have two KP400 that seem to be working ok.

IGLarrea commented 3 years ago

The HS300 is still timing out on the latest update. Particularly the energy monitoring is timing out my devices. Any updates we can expect? How can we turn this off? Thanks.

jakemauer commented 3 years ago

Seeing this on my setup with an HS300 as well. My details:

I am also running a KP400. Both it and the HS300 are blocked from WAN access.

I get the following errors for all of the HS300 outlets but not for the KP400 ones:

Error: TCP Timeout after 15000ms
[1/8/2021, 7:24:27 AM] [TplinkSmarthome] [Bed Light] emeter.getRealtime()
[1/8/2021, 7:24:27 AM] [TplinkSmarthome] Error: TCP Timeout after 15000ms
192.168.1.208:9999 {"emeter":{"get_realtime":{}},"context":{"child_ids":["80061224D4DDB78CD1B52E935607645D1D613DCA03"]}}
    at Timeout._onTimeout (/homebridge/node_modules/homebridge-tplink-smarthome/node_modules/tplink-smarthome-api/src/network/tcp-socket.ts:67:17)
    at listOnTimeout (internal/timers.js:554:17)
    at processTimers (internal/timers.js:497:7)
larcin78 commented 3 years ago

Anyone using google mesh APs and getting this? I changed out my google APs and use Eeros now and this issue has disappeared and it’s been up and running now for 30 days with no error. That’s the only thing that has changed in my network.

jakemauer commented 3 years ago

@larcin78 Good point, I'm running Ubiquiti hardware and I just noted that in my post.

cjsfj commented 3 years ago

@larcin78 Good point, I'm running Ubiquiti hardware and I just noted that in my post.

I'm also on Ubiquiti hardware. I wonder if the meshing doesn't jive with the HS300 firmware?

jakemauer commented 3 years ago

@cjsfj That would be interesting and odd. Though I'm not technically running a mesh setup, my Flex HD access point is hard wired via switches back to the UDM. I'm also not running VLANs.

cjsfj commented 3 years ago

@cjsfj That would be interesting and odd. Though I'm not technically running a mesh setup, my Flex HD access point is hard wired via switches back to the UDM. I'm also not running VLANs.

I only thought of this because my Solar and Sprinkler systems explicitly do not support mesh wifi networks. I had similar intermittent timeout/connectivity issues and both vendors told me this. I ended up creating a dedicated 2.4Ghz network on a single access point. This resolve their issues.

That being said, I'm not sure that's the issue here. When I get the timeout error from Homebridge, I always check the connectivity using the Kasa app on my phone. I don't remember a single time where the HS300 wasn't responsive using the Kasa app... So I'm not sure that mesh wifi is the issue.

larcin78 commented 3 years ago

@cjsfj That would be interesting and odd. Though I'm not technically running a mesh setup, my Flex HD access point is hard wired via switches back to the UDM. I'm also not running VLANs.

I only thought of this because my Solar and Sprinkler systems explicitly do not support mesh wifi networks. I had similar intermittent timeout/connectivity issues and both vendors told me this. I ended up creating a dedicated 2.4Ghz network on a single access point. This resolve their issues.

That being said, I'm not sure that's the issue here. When I get the timeout error from Homebridge, I always check the connectivity using the Kasa app on my phone. I don't remember a single time where the HS300 wasn't responsive using the Kasa app... So I'm not sure that mesh wifi is the issue.

The problem may not be the Kasa app or the switch but the network causing time out as the home bridge plug in is expecting a response and not getting it due to errors or timeout. Also the Kasa app may be more robust to continue to check to get a response and the plug in is not as robust.

cjsfj commented 3 years ago

The problem may not be the Kasa app or the switch but the network causing time out as the home bridge plug in is expecting a response and not getting it due to errors or timeout. Also the Kasa app may be more robust to continue to check to get a response and the plug in is not as robust.

This could totally be it. Poking around the Kasa app, I can see that the "signal strength" is only about two out of four bars. I'll probably do some work to see if I can't find some better line of sight to an AP.

jakemauer commented 3 years ago

In my case my KS300 has direct line of sight to the AP which is about 10 ft away and has good signal strength so I'd be surprised if this was the cause in my case.

larcin78 commented 3 years ago

In my case my KS300 has direct line of sight to the AP which is about 10 ft away and has good signal strength so I'd be surprised if this was the cause in my case.

Keep in mind that the wireless signal is only part of the network connection. DNS, Firmware, And many other things can cause latency in a network. Just because it shows full strength doesn’t mean there is not something else causing an issue.

jakemauer commented 3 years ago

@larcin78 Absolutely, just wanted to share the details that I'm seeing.

jdebner commented 3 years ago

Hmm, interestingly enough I am also running Ubiquiti hardware. I have USG-3 and combination of U6-Lite-US and UAP-IW-HD-US but it's line of sight so if it is a network platform issue I suspect is software & protocol related.

I have no VLANs.

jakemauer commented 3 years ago

As an update I started using Home Assistant's TP-Link integration and found the same "No Response" behavior after a while. It turns out this is a known issue and likely has more to do with TP-Link changing encryption/discovery methods for some models. Home Assistant utilizes the pyHS100 library to interface with TP-Link/Kasa devices and the bug lies with that project to fix.

More context: https://github.com/home-assistant/core/issues/43088 https://github.com/python-kasa/python-kasa/pull/117

j-coates commented 3 years ago

I'm also getting this error. Currently running Homebridge on an iMac with a HS300 connected. It seems like only one plug of the 6 would be unresponsive (though I only checked one time). The other thing that I noticed (again, only one time) was that I opened the Kasa app and everything went back to be responsive in the Home app. I'm going to test it again when it goes back down, but just thought it was interesting (even if it ends up being a coincidence).

plasticrake commented 3 years ago

I have released 6.4.0-beta.1 which has changes to improve the reliability of plugs with multiple outlets like HS300.

cjsfj commented 3 years ago

Does anyone have feedback if this beta helps to resolve the issue?

plasticrake commented 3 years ago

I haven't received any feedback, but I've released these changes out of beta

dcanderson1960 commented 3 years ago

Running the released version ... all is well since the release. Thank you!

j-coates commented 3 years ago

Anyone still experiencing this? I'm on version 6.4.0 and I still get these errors all the time:

[02/08/2021, 23:53:56] [TP-Link Smarthome.API] TCP 192.168.68.63:9999 Error: TCP Timeout after 15000ms
192.168.68.63:9999 {"emeter":{"get_realtime":{}},"context":{"child_ids":["8006095AEB9B407022A62FECA58B2AAB1D62FB9F05"]}}
    at Timeout._onTimeout (/usr/local/lib/node_modules/homebridge-tplink-smarthome/node_modules/tplink-smarthome-api/src/network/tcp-socket.ts:67:17)
    at listOnTimeout (internal/timers.js:554:17)
    at processTimers (internal/timers.js:497:7)
[02/08/2021, 23:53:56] [TP-Link Smarthome.API] [Network Switch Plug] device.send() Error: TCP Timeout after 15000ms
192.168.68.63:9999 {"emeter":{"get_realtime":{}},"context":{"child_ids":["8006095AEB9B407022A62FECA58B2AAB1D62FB9F05"]}}
    at Timeout._onTimeout (/usr/local/lib/node_modules/homebridge-tplink-smarthome/node_modules/tplink-smarthome-api/src/network/tcp-socket.ts:67:17)
    at listOnTimeout (internal/timers.js:554:17)
    at processTimers (internal/timers.js:497:7)
[02/08/2021, 23:53:56] [TP-Link Smarthome] [Network Switch Plug] emeter.getRealtime()
[02/08/2021, 23:53:56] [TP-Link Smarthome] Error: TCP Timeout after 15000ms
192.168.68.63:9999 {"emeter":{"get_realtime":{}},"context":{"child_ids":["8006095AEB9B407022A62FECA58B2AAB1D62FB9F05"]}}
    at Timeout._onTimeout (/usr/local/lib/node_modules/homebridge-tplink-smarthome/node_modules/tplink-smarthome-api/src/network/tcp-socket.ts:67:17)
    at listOnTimeout (internal/timers.js:554:17)
    at processTimers (internal/timers.js:497:7)
cjsfj commented 3 years ago

@j-coates Seems like you're getting TCP Timeouts, which to me is a different error than the TCP Socket Closed errors we were getting on this issue.

j-coates commented 3 years ago

@cjsfj Thank you, I could have sworn it was fixed at some point and then I just noticed it was constantly giving me these errors and I apparently didn't read closely enough. Lack of sleep isn't helping, thanks for pointing it out!

weitieda commented 2 years ago

192.168.50.135:9999 {"system":{"get_sysinfo":{}}}
    at Timeout._onTimeout (/usr/local/lib/node_modules/homebridge-tplink-smarthome/node_modules/tplink-smarthome-api/src/network/tcp-socket.ts:67:17)
    at listOnTimeout (node:internal/timers:559:17)
    at processTimers (node:internal/timers:502:7)
[16/04/2022, 23:43:35] [TplinkSmarthome.API] TCP 192.168.50.135:9999 Error: TCP Timeout after 15000ms
192.168.50.135:9999 {"system":{"get_sysinfo":{}}}
    at Timeout._onTimeout (/usr/local/lib/node_modules/homebridge-tplink-smarthome/node_modules/tplink-smarthome-api/src/network/tcp-socket.ts:67:17)
    at listOnTimeout (node:internal/timers:559:17)
    at processTimers (node:internal/timers:502:7)
[16/04/2022, 23:43:35] [TplinkSmarthome.API] [Office Ceiling Light] device.send() Error: TCP Timeout after 15000ms
192.168.50.135:9999 {"system":{"get_sysinfo":{}}}
    at Timeout._onTimeout (/usr/local/lib/node_modules/homebridge-tplink-smarthome/node_modules/tplink-smarthome-api/src/network/tcp-socket.ts:67:17)
    at listOnTimeout (node:internal/timers:559:17)
    at processTimers (node:internal/timers:502:7)
[16/04/2022, 23:43:50] [TplinkSmarthome.API] TCP 192.168.50.135:9999 Error: TCP Timeout after 15000ms
192.168.50.135:9999 {"system":{"get_sysinfo":{}}}
    at Timeout._onTimeout (/usr/local/lib/node_modules/homebridge-tplink-smarthome/node_modules/tplink-smarthome-api/src/network/tcp-socket.ts:67:17)
    at listOnTimeout (node:internal/timers:559:17)
    at processTimers (node:internal/timers:502:7)
[16/04/2022, 23:43:50] [TplinkSmarthome.API] [Office Ceiling Light] device.send() Error: TCP Timeout after 15000ms
192.168.50.135:9999 {"system":{"get_sysinfo":{}}}
    at Timeout._onTimeout (/usr/local/lib/node_modules/homebridge-tplink-smarthome/node_modules/tplink-smarthome-api/src/network/tcp-socket.ts:67:17)
    at listOnTimeout (node:internal/timers:559:17)
    at processTimers (node:internal/timers:502:7)```

😢recently start having these errors and in HomeKit app shows "No response" but in Kasa app everyone works fine. 

---
node v16.14.0
npm v8.5.1
homebridge-tplink-smarthome v7.0.1