Lawouach / WebSocket-for-Python

WebSocket client and server library for Python 2 and 3 as well as PyPy (ws4py 0.5.1)
https://ws4py.readthedocs.org/en/latest/
BSD 3-Clause "New" or "Revised" License
1.12k stars 289 forks source link

WSS doesn't work on Python 3.12+ #287

Closed jolaf closed 1 month ago

jolaf commented 3 months ago

The following code:

from ws4py.client.threadedclient import WebSocketClient

WebSocketClient('wss://google.com').connect()

produces the following output:

$ python test.py 
Traceback (most recent call last):
  File "test.py", line 3, in <module>
    WebSocketClient('wss://google.com').connect()
  File "/home/jolaf/.local/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'

because ssl.wrap_socket() was removed in Python 3.12.

$ python3 --version
Python 3.12.3

$ lsb_release -d
No LSB modules are available.
Description:    Ubuntu 24.04 LTS
auvipy commented 3 months ago

does this patch help? https://github.com/Lawouach/WebSocket-for-Python/pull/283

jolaf commented 3 months ago

does this patch help? #283

Yes.

jolaf commented 1 month ago

Closing as fixed by #283.