AWS IoT 上的一致超时

Consistent timeouts on AWS IoT

我正在尝试让 raspberry pi 与 IoT 服务进行通信。此时,我只是 运行ning 示例脚本。我已经生成了证书、自由访问策略并从我创建的设备中窃取了端点。当我尝试 运行 脚本时,会发生以下情况:

2016-08-06 23:30:56,282 - AWSIoTPythonSDK.core.protocol.mqttCore - DEBUG - Paho MQTT Client init.
2016-08-06 23:30:56,283 - AWSIoTPythonSDK.core.protocol.mqttCore - INFO - ClientID: basicPubSub
2016-08-06 23:30:56,283 - AWSIoTPythonSDK.core.protocol.mqttCore - INFO - Protocol: MQTTv3.1.1
2016-08-06 23:30:56,283 - AWSIoTPythonSDK.core.protocol.mqttCore - DEBUG - Register Paho MQTT Client callbacks.
2016-08-06 23:30:56,283 - AWSIoTPythonSDK.core.protocol.mqttCore - DEBUG - mqttCore init.
2016-08-06 23:30:56,284 - AWSIoTPythonSDK.core.protocol.mqttCore - DEBUG - Load CAFile from: certs/iot-root-cert.pem
2016-08-06 23:30:56,284 - AWSIoTPythonSDK.core.protocol.mqttCore - DEBUG - Load Key from: certs/xxxxx-private.pem.key
2016-08-06 23:30:56,284 - AWSIoTPythonSDK.core.protocol.mqttCore - DEBUG - Load Cert from: certs/xxxxx-certificate.pem.crt
2016-08-06 23:30:56,285 - AWSIoTPythonSDK.core.protocol.mqttCore - DEBUG - Custom setting for backoff timing: baseReconnectTime = 1 sec
2016-08-06 23:30:56,285 - AWSIoTPythonSDK.core.protocol.mqttCore - DEBUG - Custom setting for backoff timing: maximumReconnectTime = 32 sec
2016-08-06 23:30:56,285 - AWSIoTPythonSDK.core.protocol.mqttCore - DEBUG - Custom setting for backoff timing: minimumConnectTime = 20 sec
2016-08-06 23:30:56,286 - AWSIoTPythonSDK.core.protocol.mqttCore - DEBUG - Custom setting for publish queueing: queueSize = -1
2016-08-06 23:30:56,286 - AWSIoTPythonSDK.core.protocol.mqttCore - DEBUG - Custom setting for publish queueing: dropBehavior = Drop Newest
2016-08-06 23:30:56,286 - AWSIoTPythonSDK.core.protocol.mqttCore - DEBUG - Custom setting for draining interval: 0.5 sec
2016-08-06 23:30:56,287 - AWSIoTPythonSDK.core.protocol.mqttCore - DEBUG - Set maximum connect/disconnect timeout to be 10 second.
2016-08-06 23:30:56,287 - AWSIoTPythonSDK.core.protocol.mqttCore - DEBUG - Set maximum MQTT operation timeout to be 5 second
2016-08-06 23:30:56,288 - AWSIoTPythonSDK.core.protocol.mqttCore - INFO - Connection type: TLSv1.2 Mutual Authentication
2016-08-06 23:30:57,124 - AWSIoTPythonSDK.core.protocol.mqttCore - DEBUG - Disconnect result code 1
2016-08-06 23:30:58,525 - AWSIoTPythonSDK.core.protocol.mqttCore - DEBUG - Disconnect result code 1
2016-08-06 23:31:00,973 - AWSIoTPythonSDK.core.protocol.mqttCore - DEBUG - Disconnect result code 1
2016-08-06 23:31:05,463 - AWSIoTPythonSDK.core.protocol.mqttCore - DEBUG - Disconnect result code 1
2016-08-06 23:31:07,079 - AWSIoTPythonSDK.core.protocol.mqttCore - ERROR - Connect timeout.
Traceback (most recent call last):
  File "basicPubSub.py", line 153, in <module>
    myAWSIoTMQTTClient.connect()
  File "/usr/local/lib/python2.7/dist-packages/AWSIoTPythonSDK/MQTTLib.py", line 355, in connect
    return self._mqttCore.connect(keepAliveIntervalSecond)
  File "/usr/local/lib/python2.7/dist-packages/AWSIoTPythonSDK/core/protocol/mqttCore.py", line 291, in connect
    raise connectTimeoutException()
core.exception.AWSIoTExceptions.connectTimeoutException

当我尝试 websockets 时,同样的事情发生了。似乎不是可达性问题,我可以卷曲 URL 很好(尽管没有得到回应)。想法?

原来问题是您需要:

  • 在控制台中同时拥有策略和证书
  • 明确地将它们相互关联