-
Notifications
You must be signed in to change notification settings - Fork 420
Closed
Labels
feature-requestA feature should be added or improved.A feature should be added or improved.p2This is a standard priority issueThis is a standard priority issue
Description
Describe the bug
AWSIoTPythonSDK depends on ssl.wrap_socket() which was deprecated in python 3.7 and removed in python 3.12.
Below is an extract of a traceback that exposes the problem from the Home Assistant Plugin for the Navien Water Heater which uses this SDK (I believe the latest version on pypi 1.5.2). Home Assistant is just transitioning to Python 3.12 as noted here.
The full traceback can be found here nikshriv/hass_navien_water_heater#35
File "/usr/local/lib/python3.12/site-packages/AWSIoTPythonSDK/MQTTLib.py", line 520, in connect
return self._mqtt_core.connect(keepAliveIntervalSecond)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/AWSIoTPythonSDK/core/protocol/mqtt_core.py", line 196, in connect
self.connect_async(keep_alive_sec, self._create_blocking_ack_callback(event))
File "/usr/local/lib/python3.12/site-packages/AWSIoTPythonSDK/core/protocol/mqtt_core.py", line 223, in connect_async
raise e
File "/usr/local/lib/python3.12/site-packages/AWSIoTPythonSDK/core/protocol/mqtt_core.py", line 211, in connect_async
rc = self._internal_async_client.connect(keep_alive_sec, ack_callback)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/AWSIoTPythonSDK/core/protocol/internal/clients.py", line 125, in connect
rc = self._paho_client.connect(host, port, keep_alive_sec)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/AWSIoTPythonSDK/core/protocol/paho/client.py", line 665, in connect
return self.reconnect()
^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/AWSIoTPythonSDK/core/protocol/paho/client.py", line 800, in reconnect
rawSSL = ssl.wrap_socket(sock, ca_certs=self._tls_ca_certs, cert_reqs=ssl.CERT_REQUIRED) # Add server certificate verification
^^^^^^^^^^^^^^^
AttributeError: module 'ssl' has no attribute 'wrap_socket'
Expected Behavior
The library works in python 3.12.
Current Behavior
The library fails to load with the above traceback in python 3.12.
Possible Solution
As noted here in the python 3.7 release notes:
ssl.wrap_socket() is deprecated. Use ssl.SSLContext.wrap_socket() instead.
Additional Information/Context
No response
SDK version used
1.5.2
Environment details (OS name and version, etc.)
Home Assistant 2024.2
Metadata
Metadata
Assignees
Labels
feature-requestA feature should be added or improved.A feature should be added or improved.p2This is a standard priority issueThis is a standard priority issue