2016-12-01 43 views
0

我试图在我的覆盆子pi上运行python脚本。而且我的设备也已经连接在bluemix上。起初,我可以运行脚本,但现在我得到了以下错误。运行超时连接到IBM iot服务


2016年11月14日06:46:30490 ibmiotf.application.Client警告无法因为TLSv1.2工作是不可用(MQTT SSL上至少需要的Python v2.7.9或3.4和OpenSSL V1来加密消息。 0.1) 2016-11-14 06:46:40,571 ibmiotf.application.Client CRITICAL连接到IBM物联网服务的操作超时:1tlj3z.messaging.internetof things.ibmcloud.com 操作超时连接到IBM物联网的服务网络:1tlj3z.mes saging.internetofthings.ibmcloud.com

PIO.setmode(GPIO.BCM) 
GPIO.setup(18, GPIO.IN, pull_up_down=GPIO.PUD_UP) 
GPIO.setup(17, GPIO.OUT) 
client = None 
def myCommandCallback(cmd): 
if cmd.event == "light": 

有效载荷= json.loads( cmd.payload)

command = payload["command"] 
print command 
if command == "on": 
GPIO.output(17, True) 

elif的命令== “关”:

GPIO.output(17,假)

try: 
options = ibmiotf.application.ParseConfigFile("/home/pi/device.cfg") 
options["deviceId"] = options["id"] 
options["id"] = "aaa" + options["id"] 
client = ibmiotf.application.Client(options) 
client.connect() 
client.deviceEventCallback = myCommandCallback 
client.subscribeToDeviceEvents(event="light")   

while True: 
    GPIO.wait_for_edge(18, GPIO.FALLING) 
    print "Button Pushed" 
    myData = {'buttonPushed' : True} 
    client.publishEvent("raspberrypi", options["deviceId"], "input", "json", myData) 
    time.sleep(0.2) 

除了ibmiotf.ConnectionException为e: 打印E

+0

你可以添加你的代码和python版本吗?你是否检查过Pi的防火墙/互联网连接? – amadain

+0

我能够ssh到我的pi。 –

+0

ssh到pi只说pi在你的子网上。在pi上时,确保它可以ping 1tlj3z.messaging.internetofthings.ibmcloud.com。但瓦莱丽可能是正确的,你应该升级蟒蛇。 – amadain

回答

0

看来你的错误是由于你没有使用Python和OpenSSL版本来支持IoT Platform对加密连接所需的TLS v1.2。

在端口8883或443上使用安全MQTT消息时,较新的客户端库会自动信任由Watson IoT Platform提供的证书。如果这不是你的客户端环境的情况下,您可以下载并从messaging.pem

使用完整的证书链参考物联网TLS security requirements documentation

是您最初运行脚本到非SSL端口?你在域中有通配符吗?