Ape / samsungctl

Remote control Samsung televisions via a TCP/IP connection
MIT License
711 stars 191 forks source link

Fix #61 freeze/broken pipe after some idle time #88

Open ejel opened 6 years ago

ejel commented 6 years ago

When keeping long-lived websocket connection, after some idle time the connection will go into a bad state. Calling send() cause no response at first and then broken pipe error is raised on the subsequent call. The cause is that there is no designated thread to keep the socket alive.

A possible drawback is that for short-lived / one-off call a thread will still be created and thrown away. If you feel this is excessive one possible solution is to add another config flag for long-live connection and only create keep alive thread in that case. Although the flag will only be applicable to websocket implementation at the moment. Let me know how do you like to proceed.

Testing Done