aws / aws-iot-device-sdk-python

SDK for connecting to AWS IoT from a device using Python.
Apache License 2.0
683 stars 426 forks source link

AttributeError: 'SecuredWebSocketCore' object has no attribute 'pending' #299

Closed rbattle closed 2 years ago

rbattle commented 2 years ago

We are seeing errors with the python mqtt client:

Exception in thread Thread-2:
Traceback (most recent call last):
  File \"/usr/lib64/python3.7/threading.py\", line 926, in _bootstrap_inner
    self.run()
  File \"/usr/lib64/python3.7/threading.py\", line 870, in run
    self._target(*self._args, **self._kwargs)
  File \"/aws-iot-device-sdk-python/AWSIoTPythonSDK/core/protocol/paho/client.py\", line 2398, in _thread_main
    self.loop_forever()
  File \"/aws-iot-device-sdk-python/AWSIoTPythonSDK/core/protocol/paho/client.py\", line 1370, in loop_forever
    rc = self.loop(timeout, max_packets)
  File \"/aws-iot-device-sdk-python/AWSIoTPythonSDK/core/protocol/paho/client.py\", line 883, in loop
    pending_bytes = self._ssl.pending()
AttributeError: 'SecuredWebSocketCore' object has no attribute 'pending'

Connect timed out
Traceback (most recent call last):
  File \"/aws-iot-device-sdk-python/hello_world_assertion_client.py\", line 38, in <module>
    myAWSIoTMQTTClient.connect()
  File \"/aws-iot-device-sdk-python/AWSIoTPythonSDK/MQTTLib.py\", line 513, in connect
    return self._mqtt_core.connect(keepAliveIntervalSecond)
  File \"/aws-iot-device-sdk-python/AWSIoTPythonSDK/core/protocol/mqtt_core.py\", line 199, in connect
    raise connectTimeoutException()
AWSIoTPythonSDK.exception.AWSIoTExceptions.connectTimeoutException

I think it is related to https://github.com/aws/aws-iot-device-sdk-python/issues/296 and https://github.com/aws/aws-iot-device-sdk-python/pull/297

Should

    pending_bytes = self._ssl.pending()

instead be

    pending_bytes = self._ssl.getSSLSocket().pending()
bretambrose commented 2 years ago

Based on the three different branches here

https://github.com/aws/aws-iot-device-sdk-python/blob/master/AWSIoTPythonSDK/core/protocol/paho/client.py#L797

It looks like we should instead use this function here:

https://github.com/aws/aws-iot-device-sdk-python/blob/master/AWSIoTPythonSDK/core/protocol/paho/client.py#L1325

bretambrose commented 2 years ago

This should be fixed in the main branch now. I was able to run samples with both x509 mtls and websocket with sigv4 signed handshake.

I'll be adding the internal integration tests next when I have some time, and those should early-detect mistakes like this last one.

github-actions[bot] commented 2 years ago

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see. If you need more assistance, please either tag a team member or open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.