2016-12-01 20 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端口?你在域中有通配符嗎?

相關問題