我试图让树莓派与物联网服务进行沟通。此时,我只是运行示例脚本。我已经获得了一个证书,一个自由访问策略,并从我创建的设备中窃取了端点。当我尝试运行脚本时,会发生什么:
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(虽然没有得到回应)。想法?
答案 0 :(得分:3)
原来问题是你需要: