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 (-1) BasicPubSub #25

Closed BallastBoy closed 7 years ago

BallastBoy commented 7 years ago

I am stuck and getting nowhere, please could someone help?

When running the BasicPubSub example it stops at the first stage with a Setup Fail -1

AWS IoT SDK Version(dev) 2.2.0-

.iot.us-west-2.amazonaws.com 8883 /AWS-IoT-Python-Runtime/certs/root-CA.crt /AWS-IoT-Python-Runtime/certs/-private.pem.key /AWS-IoT-Python-Runtime/certs/-certificate.pem.crt yun Setup failed! -1

I have set-up an AWS IoT account and generated the keys and certificates which I loaded into the directory on yun.

root@yun:/AWS-IoT-Python-Runtime/certs# ls

-certificate.pem.crt -public.pem.key -private.pem.key root-CA.crt

I can connect to yun via WiFi and can use PuTTY and WinSCP.

I expect that it is something simple that I have not done - any pointers would be appreciated!

I have checked the keys and certificates by using MTTQ.fx and can publish and subscribe OK to AWS.

The code seems to be failing at the myClient.setup phase - not sure why this would be? Client id is "yun".

if((rc = myClient.setup(AWS_IOT_CLIENT_ID)) == 0) { // Load user configuration

liuszeng commented 7 years ago

Hi @BallastBoy ,

Thank you very much for your interest in AWS IoT Arduino Yun SDK!

The error code indicates that the Python runtime is not started/working correctly and is not returning the expected pattern of the serial commands. You can try the following things: a. Make sure that you have the Python runtime of the AWS IoT Arduino Yun SDK correctly installed on OpenWRT of your board. If you are using linux/Mac OS, there are scripts provided in the SDK package that helps you to automate these set-up procedures. For example, all-in-one installation script: https://github.com/aws/aws-iot-device-sdk-arduino-yun/blob/master/AWSIoTArduinoYunInstallAll.sh

b. Add the following line after this: https://github.com/aws/aws-iot-device-sdk-arduino-yun/blob/master/AWS-IoT-Arduino-Yun-Library/aws_iot_mqtt.cpp#L851

Serial.println(rw_buf);

It will prints out the content received from the OpenWRT, which will help us to investigate into the cause of this issue.

Please do let us know how it goes.

Thanks, Liusu

BallastBoy commented 7 years ago

Hello Liusu,

Thank you for getting back to me and for your help. When following the python installation instructions I noticed that I had a SNI missing and an insecure platform warning.

root@yun:/# pip install AWSIoTPythonSDK==1.0.0 Collecting AWSIoTPythonSDK==1.0.0 /usr/lib/python2.7/site-packages/pip-9.0.1-py2.7.egg/pip/vendor/requests/packages/urllib3/util/ssl.py:318: SNIMissingWarning: An HTTPS request has been made, but the SNI (Subject Name Indication) extension to TLS is not available on this platform. This may cause the server to present an incorrect TLS certificate, which can cause validation failures. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/security.html#snimissingwarning. SNIMissingWarning /usr/lib/python2.7/site-packages/pip-9.0.1-py2.7.egg/pip/vendor/requests/packages/urllib3/util/ssl.py:122: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/security.html#insecureplatformwarning. InsecurePlatformWarning Downloading AWSIoTPythonSDK-1.0.0.tar.gz (55kB) 100% |################################| 61kB 4.7kB/s Installing collected packages: AWSIoTPythonSDK Running setup.py install for AWSIoTPythonSDK ... done Successfully installed AWSIoTPythonSDK-1.0.0 /usr/lib/python2.7/site-packages/pip-9.0.1-py2.7.egg/pip/vendor/requests/packages/urllib3/util/ssl.py:122: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/security.html#insecureplatformwarning. InsecurePlatformWarning

I added the print command to the source code and the output is below,

yun root@yun:/# /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 /bin/ash: cd: can't cd

python: can't open file 'run.py': [Errno 2] No such file or Setup failed! -1

I am using a Windows7 machine and my Arduino yun is actually and Arduino.org device and is using Linino - I hope that this isn't causing the issues?

**Update - I believe that I am out of memory on the yun. I have remove some of the packages to try to make enough space to run the arduino sd script but it bombs out as it needs at least 1MB of flash memory to execute.... I have searched for some options but as I have Linino on the device the options to move the file system to the SD card look more complicated. Sorry, this must all be very basic for you, maybe I need to start from square 1 with the device and a clean installation on SD card? (If this is the case, please could you suggest the steps?)

root@yun:/# df Filesystem 1K-blocks Used Available Use% Mounted on rootfs 4864 4504 360 93% / /dev/root 9984 9984 0 100% /rom tmpfs 30568 108 30460 0% /tmp tmpfs 512 0 512 0% /dev /dev/mtdblock3 4864 4504 360 93% /overlay overlayfs:/overlay 4864 4504 360 93% /

Going for a cup of tea and a calm down....

OK - back again. Fresh install of Linino and also was able to execute the arduino sketch for SD card so I now have much more space. Reinstalled the packages and the BasicPubSub is working better although I am not seeing the messages that are published in AWS when i subscribe to "topic1".

Output from the basicPubSub with the additional print statement that you recommended below,

AWS IoT SDK Version(dev) 2.2.0-

a11wmzjhoph8yb.iot.us-west-2.amazonaws.com 8883 /root/AWS-IoT-Python-Runtime/certs/root-CA.crt /root/AWS-IoT-Python-Runtime/certs/d2b278c6c3-private.pem.key /root/AWS-IoT-Python-Runtime/certs/d2b278c6c3-certificate.pem.crt yun

t@yun:~/AWS-IoT-Python-Runtime/runtime# 1 /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 /

I T

G T

C T

S T

P T

Z T

Y F: No messages. loop 0 done

P6F: Offline publish request dropped because queueing is disabl Publish failed! -41

Z T

Y 0 0 new message 0 CALLBACK: new message 0

Y F: No messages. loop 1 done

P6F: Offline publish request dropped because queueing is disabl Publish failed! -41

Z T

Y F: No messages. loop 2 done

P6F: Offline publish request dropped because queueing is disabl Publish failed! -41

Z T

Y F: No messages. loop 3 done

P T

Z T

Y F: No messages. loop 4 done

P T

Z T

Y 0 0 new message 4 CALLBACK: new message 4

Y F: No messages. loop 5 done

Regards, David.

BallastBoy commented 7 years ago

Hit wrong button - sorry did not mean to close....doh....

BallastBoy commented 7 years ago

OK - all working OK now.

1) Added SD card. 2) Fresh install of Linino. 3) Installation of files using the installation guide. 4) CHMOD the permission for run.py to give execution rights.

Thanks for you support Liusu and apologies for such a long post.

David.

mumairkhugyani commented 7 years ago

@BallastBoy, I am facing the same issue. Will you please explain all steps as I am new to all this stuff and have no knowledge about this.