2

我正在尝试让树莓派与物联网服务进行通信。此时,我只是运行示例脚本。我生成了一个证书,一个自由访问策略,并从我创建的设备中窃取了端点。当我尝试运行脚本时,会发生以下情况:

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(尽管没有响应)。想法?

4

1 回答 1

3

原来的问题是你需要:

  • 在控制台中同时拥有策略和证书
  • 明确地将它们相互关联
于 2016-08-08T18:48:58.640 回答