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

Setup failed! - PubSub sample #30

Closed eczajk1 closed 7 years ago

eczajk1 commented 7 years ago

Can you offer any advice on the best way to diagnose this error:

AWS IoT SDK Version(dev) 2.2.0-

Setup failed!
-1

My config file is:

//===============================================================
#define AWS_IOT_MQTT_HOST "a27sg7ieezj192.iot.us-east-1.amazonaws.com"  // your endpoint
#define AWS_IOT_MQTT_PORT 8883  // your port
#define AWS_IOT_CLIENT_ID "seeed02" // your client ID
#define AWS_IOT_MY_THING_NAME "seeed-czajk02"   // your thing name
#define AWS_IOT_ROOT_CA_FILENAME "root-CA.crt"  // your root-CA filename
#define AWS_IOT_CERTIFICATE_FILENAME "hashed-certificate.pem.crt"   // your certificate filename
#define AWS_IOT_PRIVATE_KEY_FILENAME "hashed-private.pem.key"   // your private key filename
//===============================================================

Seems like I have been successful running the python sdk example, as a test (as was suggested in #28):

root@Seeed:~/aws-iot-device-sdk-python/samples/basicPubSub# python basicPubSub.py -e a27sg7ieezj192.iot.us-east-1.amazonaws.com -r ../../../AWS-IoT-Python-Runtime/certs/root-CA.crt -c
../../../AWS-IoT-Python-Runtime/certs/c51fbd44a5-certificate.pem.crt -k ../../../AWS-IoT-Python-Runtime/certs/c51fbd44a5-private.pem.key
2017-01-30 14:40:59,759 - AWSIoTPythonSDK.core.protocol.mqttCore - DEBUG - Paho MQTT Client init.
2017-01-30 14:40:59,763 - AWSIoTPythonSDK.core.protocol.mqttCore - INFO - ClientID: basicPubSub
2017-01-30 14:40:59,767 - AWSIoTPythonSDK.core.protocol.mqttCore - INFO - Protocol: MQTTv3.1.1
2017-01-30 14:40:59,770 - AWSIoTPythonSDK.core.protocol.mqttCore - DEBUG - Register Paho MQTT Client callbacks.
2017-01-30 14:40:59,773 - AWSIoTPythonSDK.core.protocol.mqttCore - DEBUG - mqttCore init.
2017-01-30 14:40:59,777 - AWSIoTPythonSDK.core.protocol.mqttCore - DEBUG - Load CAFile from: ../../../AWS-IoT-Python-Runtime/certs/root-CA.crt
2017-01-30 14:40:59,780 - AWSIoTPythonSDK.core.protocol.mqttCore - DEBUG - Load Key from: ../../../AWS-IoT-Python-Runtime/certs/c51fbd44a5-private.pem.key
2017-01-30 14:40:59,783 - AWSIoTPythonSDK.core.protocol.mqttCore - DEBUG - Load Cert from: ../../../AWS-IoT-Python-Runtime/certs/c51fbd44a5-certificate.pem.crt
2017-01-30 14:40:59,788 - AWSIoTPythonSDK.core.protocol.mqttCore - DEBUG - Custom setting for backoff timing: baseReconnectTime = 1 sec
2017-01-30 14:40:59,791 - AWSIoTPythonSDK.core.protocol.mqttCore - DEBUG - Custom setting for backoff timing: maximumReconnectTime = 32 sec
2017-01-30 14:40:59,795 - AWSIoTPythonSDK.core.protocol.mqttCore - DEBUG - Custom setting for backoff timing: minimumConnectTime = 20 sec
2017-01-30 14:40:59,799 - AWSIoTPythonSDK.core.protocol.mqttCore - DEBUG - Custom setting for publish queueing: queueSize = -1
2017-01-30 14:40:59,802 - AWSIoTPythonSDK.core.protocol.mqttCore - DEBUG - Custom setting for publish queueing: dropBehavior = Drop Newest
2017-01-30 14:40:59,806 - AWSIoTPythonSDK.core.protocol.mqttCore - DEBUG - Custom setting for draining interval: 0.5 sec
2017-01-30 14:40:59,810 - AWSIoTPythonSDK.core.protocol.mqttCore - DEBUG - Set maximum connect/disconnect timeout to be 10 second.
2017-01-30 14:40:59,813 - AWSIoTPythonSDK.core.protocol.mqttCore - DEBUG - Set maximum MQTT operation timeout to be 5 second
2017-01-30 14:40:59,817 - AWSIoTPythonSDK.core.protocol.mqttCore - INFO - Connection type: TLSv1.2 Mutual Authentication
2017-01-30 14:41:00,579 - AWSIoTPythonSDK.core.protocol.mqttCore - INFO - Connected to AWS IoT.
2017-01-30 14:41:00,581 - AWSIoTPythonSDK.core.protocol.mqttCore - DEBUG - Connect time consumption: 60.0ms.
2017-01-30 14:41:00,578 - AWSIoTPythonSDK.core.protocol.mqttCore - DEBUG - Connect result code 0
2017-01-30 14:41:00,590 - AWSIoTPythonSDK.core.protocol.mqttCore - DEBUG - Started a subscribe request 1
2017-01-30 14:41:00,882 - AWSIoTPythonSDK.core.protocol.mqttCore - DEBUG - _resubscribeCount: -1
2017-01-30 14:41:00,887 - AWSIoTPythonSDK.core.protocol.mqttCore - DEBUG - Subscribe request 1 succeeded. Time consumption: 290.0ms.
2017-01-30 14:41:00,890 - AWSIoTPythonSDK.core.protocol.mqttCore - DEBUG - Recover subscribe context for the next request: subscribeSent: False
2017-01-30 14:41:00,885 - AWSIoTPythonSDK.core.protocol.mqttCore - DEBUG - Subscribe request 1 sent.
2017-01-30 14:41:02,898 - AWSIoTPythonSDK.core.protocol.mqttCore - DEBUG - Try to put a publish request 2 in the TCP stack.
2017-01-30 14:41:02,901 - AWSIoTPythonSDK.core.protocol.mqttCore - DEBUG - Publish request 2 succeeded.
Received a new message:
New Message 0
from topic:
sdk/test/Python
--------------

2017-01-30 14:41:03,909 - AWSIoTPythonSDK.core.protocol.mqttCore - DEBUG - Try to put a publish request 3 in the TCP stack.
2017-01-30 14:41:03,912 - AWSIoTPythonSDK.core.protocol.mqttCore - DEBUG - Publish request 3 succeeded.
Received a new message:
New Message 1
from topic:
sdk/test/Python
--------------
eczajk1 commented 7 years ago

This is my output after adding the print statement as was suggested on #25:

root@Seeed:~/AWS-IoT-Python-Runtime/runtime# 
/bin/ash: 1: not found
/bin/ash: /root: Permission denied
/bin/ash: 1: not found
/bin/ash: /root: Permission denied
/bin/ash: 1: not found
/bin/ash: /root: Permission denied
/bin/ash: 1: not found
/bin/ash: /root: Permission denied
Linux
/

Traceback (most recent call last):
Setup failed!
-1
eczajk1 commented 7 years ago

I was able to get this to work after reinstalling the AWSIoTPythonSDK and re-uploading the Python runtime folder. 😖

Victor9936084 commented 7 years ago

@eczajk1 Thanks, i have the same issue as you had, and i will do what you did, and one more question: how to set the AWS_IOT_CLIENT_ID? you set it as seeed02, where is seeed02 from? Thanks again!

liuszeng commented 7 years ago

Hi @Victor9936084 ,

AWS_IOT_CLIENT_ID is the client side identifier you use to connect to AWS IoT. You can configure it by yourself by changing the macros in aws_iot_config.h. Take "BasicPubSub" as an example, you can configure the your client id here: https://github.com/aws/aws-iot-device-sdk-arduino-yun/blob/master/AWS-IoT-Arduino-Yun-Library/examples/BasicPubSub/aws_iot_config.h#L23

Hope the above helps.

Thanks, Liusu

Victor9936084 commented 7 years ago

Hi @liuszeng ,

Thanks for your kindly response, and i'd apologize for my poor english, actually i know where i can set AWS_IOT_CLIENT_ID macro, but i don't know what value should i set, in the example you give to me:

define AWS_IOT_CLIENT_ID "My_ClientID" // your client ID

the value is "My_ClientID". and for me, how can i get(set) the client ID from my Arduino Yun board?

Thanks again! Victor

eczajk1 commented 7 years ago

This thread helped clear it up a little for me: https://forums.aws.amazon.com/thread.jspa?threadID=219513

MQTT client IDs do not have an association with a Thing in AWS IoT. These client IDs are purely to uniquely identify the MQTT connection. One important thing to consider about MQTT client IDs is they need to be unique among devices across your AWS account. If you have a client connected as "client ID 1" and a second client connects with that same ID ("client ID 1") then first client's connection will be force disconnected. This is a feature of the MQTT spec that keeps a client with intermittent connectivity from spawning multiple MQTT sessions.

Victor9936084 commented 7 years ago

thank you @eczajk1 , after set the client ID, i still get failed:

  1. connect fail error -1(AWSIoTPythonSDK==1.0.0)
  2. setup fail error -1(AWSIoTPythonSDK==1.1.1) so i'd like to run the python sdk example as a test (as was suggested in #28), but i got error message "No space left on the device" when i followed the steps (afer install git), do i need a micro SD card to expand the space? thanks a lot. @eczajk1 @liuszeng
liuszeng commented 7 years ago

Hi @Victor9936084 ,

The current version of AWS IoT Arduino Yun SDK is backed by AWS IoT Python SDK v1.0.0. To get it working correctly, you will need to have AWS IoT Python SDK v1.0.0 installed on your OpenWRT.

For the connect failure, Can you verify that the certificate you used is attached with a policy with proper permissions? For more details about AWS IoT Policy, you can take a look at the following link: http://docs.aws.amazon.com/iot/latest/developerguide/pub-sub-policy.html

Thanks, Liusu

Victor9936084 commented 7 years ago

I was able to get this to work after setting policy on AWS IOT(give full permission) and setting serial baud rate to 115200, thank you all.

m3tavi3w commented 5 years ago

Hello,

Finally,I have the same problem with the Dragino Yun Shield (Permission denied and Setup failed! -1).

I already tested the credentials for X.509 and permissions: it worked fine with the Arduino Yun.

Before I updated the Firmware on the Yun Shield, I got the CONNECT_SSL_ERROR -10). When I installed the AWSIoTPythonSDK 1.0.0, I regonized the following Warnings: "Insecure PlatformWarning" and "SNIMissingWarning". So i updated the Firmware to Dragino-v2 yun-4.1.2. and got no more Warnings.

Has somebody an advice?

Many thanks in advance.