bitfocus / companion-module-tplink-kasasmartbulb

MIT License
0 stars 1 forks source link

Not closing udp sockets #2

Closed Julusian closed 1 year ago

Julusian commented 2 years ago

https://github.com/bitfocus/companion-module-tplink-kasasmartbulb/blob/71c7c9ee35d85081635a858db2fdf34b485bbef6/src/actions.js#L31

Every time send is called it is opening a new udp socket on a random port. But you are only closing them if you get a response. If the device does not respond will eventually lead to exhausting all the possible port numbers, and stop things from working (eg https://github.com/bitfocus/companion/issues/2108)

You need to make sure to fail the call after some timeout, and clean it up, or it might be better to create the socket once as part of init and updateConfig and reuse it? It will require more care when listening for responses, but will ensure this can never happen

josephdadams commented 2 years ago

Oops, I’ll fix this

isaiahfranco commented 2 years ago

Thanks, guys! That was a lot of fun trying to nail down the source of the bug...

josephdadams commented 2 years ago

@isaiahfranco can you help me test?

isaiahfranco commented 2 years ago

@josephdadams Of course!

isaiahfranco commented 2 years ago

@josephdadams What do you need me to do?

josephdadams commented 2 years ago

I’ll ping you when I have it ready. I forgot that I started rewriting it awhile back to fix this bug and add some stuff 😂

isaiahfranco commented 1 year ago

@josephdadams Strangely enough, this issue has gotten worse lately. Today alone, I've had to quit and restart Companion three times. Any ETA on when the update will be ready?

josephdadams commented 1 year ago

I have not had time to come back to it...

isaiahfranco commented 1 year ago

@josephdadams @Julusian Is there anyone that can take a look at this issue? It's causing me to restart Companion every time one of my bulbs or plugs goes offline.

josephdadams commented 1 year ago

@isaiahfranco have you tried the latest code?

Julusian commented 1 year ago

@josephdadams I don't see this as being fixed. Both times reject( is called, it still isnt closing the socket https://github.com/bitfocus/companion-module-tplink-kasasmartbulb/blob/master/src/utils.js#L170-L182

On an unrelated note, the parsing of variables looks to be broken, having not been updated to the new way needed for 3.0 https://github.com/bitfocus/companion-module-tplink-kasasmartbulb/blob/master/src/actions.js#L31-L33

josephdadams commented 1 year ago

@digitaldrummerj can you take a look? I don't think I have any of these bulbs anymore

digitaldrummerj commented 1 year ago

@Julusian @josephdadams just submitted PR to hopefully fix the sockets close and parsing variable issue.