eslavnov / pylips

Control Philips TVs (2015+) and Ambilight (+ Hue) through their reverse-engineered API (+ MQTT support!)
MIT License
342 stars 60 forks source link

[BUG] Android TV 32PFS6402 : SSL handshake time out #38

Closed GreenSnakeLinux closed 4 years ago

GreenSnakeLinux commented 5 years ago

Hello

I have a SSL handshake time out that occurs very often. The only way I found to bypass is to restart the Android OS of the TV, but after a while it appears again, here is the log:

https://192.168.1.27:1926/6/pair/request Traceback (most recent call last): File "C:\Python35\lib\site-packages\urllib3\connectionpool.py", line 344, in _make_request self._validate_conn(conn) File "C:\Python35\lib\site-packages\urllib3\connectionpool.py", line 843, in _validate_conn conn.connect() File "C:\Python35\lib\site-packages\urllib3\connection.py", line 370, in connect sslcontext=context) File "C:\Python35\lib\site-packages\urllib3\util\ssl.py", line 368, in ssl_wrap_socket return context.wrap_socket(sock) File "C:\Python35\lib\ssl.py", line 376, in wrap_socket _context=self) File "C:\Python35\lib\ssl.py", line 747, in init self.do_handshake() File "C:\Python35\lib\ssl.py", line 983, in do_handshake self._sslobj.do_handshake() File "C:\Python35\lib\ssl.py", line 628, in do_handshake self._sslobj.do_handshake() socket.timeout: _ssl.c:629: The handshake operation timed out

Do you know why and how to correct it ? PS: I have the last firmware on the TV

eslavnov commented 5 years ago

Thank you for the report! Are you running pair request several times? You should run it only once to get the username and password. Spamming the 'pair' endpoint indeed results in SSL errors for some reason.

Or did I misunderstand your issue?

GreenSnakeLinux commented 5 years ago

Yes you're right. After several TV reboot, I manage to pair. But now when I send the 'Mute' command for example I have sometime this error message : {"error": "Can not reach the API"}

Even if I reboot the TV this error come times to times, I need to wait some hours to get it working again. I don't know if it's my TV that is bugged, or the TV API are not stable.

eslavnov commented 5 years ago

I've had the same issue with the pairing mechanism. As I've mentioned, running several 'pair' commands in a row breaks something in the API. Not sure if it's me doing something wrong or it's indeed an API problem.

How exactly did you reboot? What helps me is to pull the TV's plug for like 10 seconds - then the TV properly reboots and the API is working again (until you spam it with 'pair' requests again, but since you've already paired you should be fine). Can you please try this and let me know if your issue persists?

GreenSnakeLinux commented 5 years ago

I reboot using the android reboot mechanism, it's like unplug for 10s. I confirm it work again. The thing i'm facing off now is if I spam the Mute command for example, i've got a 403 error: Cannot reach the api. The reboot will not fix this pb, i need to pair again or wait like 10mn, it's weird.

eslavnov commented 5 years ago

What happens with the power plug method? Software reboots didn't work for me either, only the power plug. I am 99% sure that the API is not running in Android based on my experience with it and lack of input sources switching (which is trivial from Android, so why does not the API support?).

GreenSnakeLinux commented 5 years ago

Power plug seems the same than soft reboot. If I don't spam it works. It seems that there is a mechanism in the api that prevent denial of service and ask for pairing again. When i use up, down, left, right in Netflix app i need to be careful to not be too fast

eslavnov commented 4 years ago

Seems like it's an issue on the API side, there is nothing I can do, unfortunately.