简体   繁体   中英

operation time out connection to IBM iot service

I was trying run the python script on my raspberry pi. And my device is also already connected on bluemix. At first, I could able to run the script but now I got the following error.


2016-11-14 06:46:30,490 ibmiotf.application.Client WARNING Unable to encrypt messages because TLSv1.2 is unavailable (MQTT over SSL requires at least Python v2.7.9 or 3.4 and openssl v1.0.1) 2016-11-14 06:46:40,571 ibmiotf.application.Client CRITICAL Operation timed o ut connecting to the IBM Internet of Things service: 1tlj3z.messaging.internetof things.ibmcloud.com Operation timed out connecting to the IBM Internet of Things service: 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":

payload = json.loads(cmd.payload)

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

elif command == "off":

GPIO.output(17, False)

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)

except ibmiotf.ConnectionException as e: print e

It appears your error is due to the fact you are not using Python and OpenSSL versions to support TLS v1.2 which is required by IoT Platform for encrypted connections.

When you use secure MQTT messaging on ports 8883 or 443, newer client libraries automatically trust the certificate that is presented by Watson IoT Platform. If this is not the case for your client environment, you can download and use the full certificate chain from messaging.pem

Refer to IoT TLS security requirements documentation

Were you originally running the script to a non-SSL port? Do you have a wildcard in the domain?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM