2017-10-10 82 views
0

我工作的谷歌云计算物联网的核心和有我在在线文档中提供的样品(终端到终端的例子)的一个横跨问题就来了:google cloud iot exercise谷歌云计算物联网核心锻炼

有两种脚本,用于服务器和设备,并同时运行设备脚本,我面临这个问题:

+0

的那些脚本的代码是: - https://github.com/aadharbhatt/pub-sub-work/blob/master/cloudiot_pubsub_example_mqtt_device.py https://github.com/aadharbhatt/ pub-sub-work/blob/master/cloudiot_pubsub_example_server.py –

+0

__Please添加一些细节到您的文章本身和标题.__ 这不是一个聊天框,而是一个问题解决库。问题应该仔细编辑,这样不仅那些可以提供解决方案的人,而且那些在不同环境中有类似问题的人都可以在未来找到你的问题。 –

回答

0

这有可能是您的防火墙(例如云弹机)从通过端口8883.可在连接阻塞的Python您尝试调用端口设置为443的cloudiot_pubsub_example_mqtt_device.py脚本,例如

python <your_existing_parameters> --mqtt_bridge_port=443 

您还可以尝试使用the HTTP device sample,因为它也没有使用端口8883,这可能被阻止在网络上发布消息尝试。

在我的测试中,我只能在将端口设置为443后从Google云端Shell运行练习,这有望为您解决问题。

注意如果您遇到与验证服务器证书的问题,需要通过调用下载谷歌根证书:

wget https://pki.google.com/roots.pem 
+0

在端口443 ssl证书验证失败 –

+0

添加了注释,您可能需要调用wget https://pki.google.com/roots.pem – class

0

error image

Traceback (most recent call last): 
    File "cloudiot_pubsub_example_mqtt_device.py", line 249, in <module> 
    main() 
    File "cloudiot_pubsub_example_mqtt_device.py", line 213, in main 
    client.connect(args.mqtt_bridge_hostname, args.mqtt_bridge_port) 
    File "/usr/local/lib/python2.7/dist-packages/paho/mqtt/client.py", line 
768, in connect 
    return self.reconnect() 
    File "/usr/local/lib/python2.7/dist-packages/paho/mqtt/client.py", line 
927, in reconnect 
    sock.do_handshake() 
    File "/usr/lib/python2.7/ssl.py", line 788, in do_handshake 
    self._sslobj.do_handshake() 
ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed 
(_ssl.c:581) 
1

从命令行指定参数时,它看起来像在传递rsa_cert.pem,这是您的SSL私钥。正如@class所说的,您需要获取Google根证书(wget https://pki.google.com/roots.pem),然后将路径传递给下载的root.pem作为--ca_certs参数。