当我尝试使用aws-iot-python-sdk连接到AWS IOT时,出现此WebSocket握手错误。我正在使用WebSocket + MQTT版本发布和接收数据。非常奇怪的是,它在几个小时前运行良好,没有一行代码更改,只是开始引发错误,我很困惑发生了什么?是AWS IOT本身还是在我这边发生了什么!!!
我用于连接到AWS IOT的代码。
from AWSIoTPythonSDK.MQTTLib import AWSIoTMQTTClient
from config import IOT_ENDPOINT, IOT_CREDENTIAL_PATH
def connect(mqttClientId):
try:
myMQTTClient = AWSIoTMQTTClient(mqttClientId, useWebsocket=True)
myMQTTClient.configureEndpoint(IOT_ENDPOINT, 443)
myMQTTClient.configureCredentials(IOT_CREDENTIAL_PATH)
myMQTTClient.configureAutoReconnectBackoffTime(1, 32, 20)
# Infinite offline Publish queueing
myMQTTClient.configureOfflinePublishQueueing(-1)
myMQTTClient.configureDrainingFrequency(2) # Draining: 2 Hz
myMQTTClient.configureConnectDisconnectTimeout(10) # 10 sec
myMQTTClient.configureMQTTOperationTimeout(5) # 5 sec
myMQTTClient.connect()
return myMQTTClient
except Exception as error:
print(error)
print "No Internet Connection... Can't connect AWS IOT"
谢谢。