aws / aws-iot-device-sdk-arduino-yun

SDK for connecting to AWS IoT from an Arduino Yún.
Apache License 2.0
163 stars 77 forks source link

SSL Connection Error -10 #46

Closed 3141592658979 closed 7 years ago

3141592658979 commented 7 years ago

Using a Seeeduino Cloud (essentially like the Arduino Yun). My code was working fine. I got everything to how I wanted it. Then, I did not plug it in for a couple weeks. AWS, it appears (this is a guess) clears out all records of an IoT Thing after no activity for two weeks. So when I logged back in one day, I found nothing registered, no certificates, no policy, everything gone.

So, I had to create it all again.

Uploaded the new certificate files onto the board. Changed the file names in the sketch's aws_iot_config.h . Now it gives an error -10 when running the example sketches, which I see is CONNECT_SSL_ERROR = -10.

Any idea what would cause this? Any way to "reset" the Dragino board to pristine condition and then do everything over? But perhaps that would not solve it -- it may be a problem on the cloud end? I did set up IAM in the meantime -- would that break it?

hedeshianaws commented 7 years ago

Thank you for your interest in the AWS IoT SDK.

I logged back in one day, I found nothing registered, no certificates, no policy, everything gone

This shouldn't be the case. I would recommend checking with AWS customer service to see what might be going on here.

CONNECT_SSL_ERROR = -10.

This means the TLS handshake failed and is most likely caused by a certificate mismatch between the cloud and your device. Things you could check are:

Any way to "reset" the Dragino board to pristine condition and then do everything over

Unfortunately, I have no advice here. However, from your error, I don't think this is necessary.

I did set up IAM in the meantime

Can you give a little more details on what you did? (please don't post sensitive information here such as account or user names / certs, etc...)

3141592658979 commented 7 years ago

OK, everything is working again! The solution was:

"* Make sure you are using the correct IoT dataplane endpoint for your account"

I don't actually understand what all those words mean, but I interpreted them to mean "maybe you're trying to connect to the wrong server" and, sure enough, I was! Somehow the server had changed from Oregon to Ohio -- you can check this in the top-right corner of the web page when you're logged in to AWS. So, in Ohio, I had nothing set up. I had re-set-up everything in Ohio, but not changed the line in aws_iot_config.h from

define AWS_IOT_MQTT_HOST "a123aaaa1a1aaa.iot.us-west-2.amazonaws.com"

to

define AWS_IOT_MQTT_HOST "a123aaaa1a1aaa.iot.us-east-2.amazonaws.com"

so then that wasn't working either!

Now both and either set up will work -- the original certs linking to Oregon (...west-2...) and the new certs linking to Ohio (...east-2...).

Thanks, hedeshian! And I hope this may help someone else. If you find your Things all suddenly disappeared, check all the other server locations!

hedeshianaws commented 7 years ago

I'm glad you were able to figure it out! Please do let us know if you have any additional questions.

I interpreted them to mean "maybe you're trying to connect to the wrong server"

You are 100% correct. "gibberish.iot.region.amazonaws.com" is the IoT dataplane endpoint. This endpoint is the host-name the SDK uses to talk to the AWS IoT MQTT service (the "pub/sub" service).

Somehow the server had changed from Oregon to Ohio

Good catch. I didn't even think about that. The web console may not remember the last region you were working in.