You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Some devices will support SSL, some will not, of those which do, some may support plaintext. It makes most sense for us to take the most secure option and failover to the least secure option.
One slight complication with this for now, is that ws4py is using ssl.wrap_socket when SSL is enabled, which was marked as deprecated in Python 3.7 and removed in Python 3.12, so it makes lgtv fail like this:
~ % lgtv --ssl swInfo
Traceback (most recent call last):
File "/Users/jeppe/.local/bin/lgtv", line 33, in <module>
sys.exit(load_entry_point('LGTV', 'console_scripts', 'lgtv')())
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/jeppe/my-git/LGWebOSRemote/LGTV/__init__.py", line 191, in main
ws.connect()
File "/Users/jeppe/.local/pipx/venvs/lgtv/lib/python3.12/site-packages/ws4py/client/__init__.py", line 214, in connect
self.sock = ssl.wrap_socket(self.sock, **self.ssl_options)
^^^^^^^^^^^^^^^
AttributeError: module 'ssl' has no attribute 'wrap_socket'
There's a fix for ws4py in Lawouach/WebSocket-for-Python#283, but I wonder if it might otherwise be worth looking at migrating to another websocket library that is kept more up to date, as ws4py hasn't had a release since 2018?
@Tenzer ws4py was the only one I found that I could make work - specifically, I had to exclude default headers in order to make it work back on webOS 2.x IIRC. You'll find this in the code where exclude_headers=['Origin'] IIRC, which was always being sent by ws4py (it IS part of the spec, so you can't blame them).
This is in itself a bit of a hack, and was likely due to a bug in the webOS web socket server libraries and may now have been fixed.
I tried @cmer 's suggestion of rolling back to Python 3.6 but got the following error:
% brew install python@3.6
Warning: No available formula with the name "python@3.6". Did you mean python@3.9, python@3.8, python@3.7, python@3.10, python@3.12, python@3.11 or python-yq?
==> Searching for similarly named formulae and casks...
==> Formulae
python@3.9 python@3.8 python@3.7 python@3.10 python@3.12 python@3.11 python-yq
Activity
Tenzer commentedon Dec 9, 2023
One slight complication with this for now, is that ws4py is using
ssl.wrap_socketwhen SSL is enabled, which was marked as deprecated in Python 3.7 and removed in Python 3.12, so it makeslgtvfail like this:There's a fix for ws4py in Lawouach/WebSocket-for-Python#283, but I wonder if it might otherwise be worth looking at migrating to another websocket library that is kept more up to date, as ws4py hasn't had a release since 2018?
klattimer commentedon Dec 11, 2023
@Tenzer ws4py was the only one I found that I could make work - specifically, I had to exclude default headers in order to make it work back on webOS 2.x IIRC. You'll find this in the code where exclude_headers=['Origin'] IIRC, which was always being sent by ws4py (it IS part of the spec, so you can't blame them).
This is in itself a bit of a hack, and was likely due to a bug in the webOS web socket server libraries and may now have been fixed.
Aurshur commentedon Dec 30, 2023
Is there any workaround with this?
I tried @cmer 's suggestion of rolling back to Python 3.6 but got the following error:
% brew install python@3.6
Warning: No available formula with the name "python@3.6". Did you mean python@3.9, python@3.8, python@3.7, python@3.10, python@3.12, python@3.11 or python-yq?
==> Searching for similarly named formulae and casks...
==> Formulae
python@3.9 python@3.8 python@3.7 python@3.10 python@3.12 python@3.11 python-yq
Tenzer commentedon Dec 30, 2023
The problem only exists with Python 3.12, so try version 3.11 for now.
Aurshur commentedon Jan 6, 2024
That worked! Thank you!
egnappahz commentedon Apr 28, 2024
I'm sorry, but the real fix is
https://github.com/Lawouach/WebSocket-for-Python/pull/283/files/1d9ffff3beb71553c85e846a1b828ec7d890e751
Not all of us can afford to use ancient versions of python.