CC3220 echo demo -- Handshake Failed - socket 0, reason: -457.

lph65724 wrote on April 08, 2019:

I have been following the getting started guide and trying to run the demo but without success. All I have got in the console is handshake failed as the following

0 0 [Tmr Svc] Starting Wi-Fi Module …
1 0 [Tmr Svc] Simple Link task created
Device came up in Station mode
2 162 [Tmr Svc] Wi-Fi module initialized.
3 175 [Tmr Svc] Write certificate…
4 283 [Tmr Svc] Write device private key…
5 800 [Tmr Svc] Write certificate…
[WLAN EVENT] STA Connected to the AP: xxxxx , BSSID: d0:17:c2:d7:32:f8
[NETAPP EVENT] IP acquired by the device

Device has connected to xxxxx
Device IP Address is 192.168.16.196

6 2130 [Tmr Svc] Wi-Fi connected to AP xxxxx.
7 2131 [Tmr Svc] IP Address acquired xxx.xxx.xx.xxx
8 2134 [Tmr Svc] Security alert threshold = 15
9 2134 [Tmr Svc] Current number of alerts = 0
10 2134 [Tmr Svc] Creating MQTT Echo Task…
11 2134 [MQTTEcho] MQTT echo attempting to connect to xxxxxxxxxxxxx-ats.iot.ap-northeast-1.amazonaws.com.
12 2387 [pthread] [SimpleLinkSockEventHandler ERROR]: Handshake Failed - socket 0, reason: -457.
13 2388 [MQTTEcho] ERROR: MQTT echo failed to connect with error 1.
14 2388 [MQTTEcho] MQTT echo test could not connect to broker.
15 2409 [MQTTEcho] MQTT echo demo finished.
16 2409 [MQTTEcho] ----Demo finished----

does anyone know what reason: -457 indicate? Any advice?

ravishankar-AWS wrote on April 13, 2019:

Hi,

Error number ( -457 ) is for SL_ERROR_BSD_ESECBADCERTFILE
#define SL_ERROR_BSD_ESECBADCERTFILE (-457L) /* error secure level bad Certificate file */
For reference, you can find the list of all SSL error codes here: [https://github.com/aws/amazon-freertos/blob/master/lib/third_party/mcu_vendor/ti/SimpleLink_CC32xx/v2_10_00_04/source/ti/drivers/net/wifi/errors.h]

Could you check if a valid certificate file and a root certificate is provided ?

lph65724 wrote on April 15, 2019:

Hi ravishankar-AWS,

Thank you for reply.
My CA is hard coded in \AmazonFreeRTOS\lib\include\private\aws_default_root_certificates.h, and certificates were downloaded from AWS, so I assume they are valid.

Thank you

ravishankar-AWS wrote on April 15, 2019:

Hi lph65724
Sorry to hear that the demo is not working for you.

The error comes from TI networking processor, and it relates to either the certificate format is wrong or there was a failure writing the certificate to the File System.
Known reasons for the error is documented in TI programmers guide here:http://www.ti.com/lit/ug/swru455g/swru455g.pdf

Could you confirm if you generated the header file (aws_clientcredential_keys.h) using the Certificate configuration tool located in <Base_Folder>/tools/certificate_configuration/CertificateConfigurator.html ?
For more details on how to generate the header file, you can refer to this guide: https://docs.aws.amazon.com/freertos/latest/userguide/freertos-configure.html

It could be that the certificate DEFINE is missing newline characters at the end, or truncated.

Please let us know if the above suggestions fixed your issue.

lph65724 wrote on April 16, 2019:

Hi ravishankar-AWS,

Yes, I used Certificate configuration tool located in <Base_Folder>/tools/certificate_configuration/CertificateConfigurator.html to generate aws_clientcredential_keys.h, and each line of the certificate ends with a newline character like shown below.

XDn+ZW
"
L3FLz4
"\

thank you

ravishankar-AWS wrote on April 16, 2019:

Hi,

I was able to run the MQTT echo demo successfully using TI CC3220 connecting to broker endpoint in ap-northeast-1 region. Here are the steps I did:

  1. Create a thing in AWS IOT ap-northeast-1 region.
  2. Create a certificate using “one click certificate creation”.
  3. Activate the certificate, and download the certificate and private key to the filesystem.
  4. Attach a valid policy to the certificate.
  5. User CertificateConfigurator.html to generate aws_clientcredential_keys.h from the client certificate and private key and replace the original aws_clientcredenial_keys.h file with the new file.
  6. Configure other credentials like MQTT broker endpoint, WIFI AP name and password.
  7. Run the demo.

Here are the logs:

0 0 [Tmr Svc] Starting Wi-Fi Module …
1 0 [Tmr Svc] Simple Link task created
2 329 [Tmr Svc] Wi-Fi module initialized.
3 338 [Tmr Svc] Write certificate…
4 449 [Tmr Svc] Write device private key…
5 967 [Tmr Svc] Write certificate…
[WLAN EVENT] STA Connected to the AP: xxxxxxxx, BSSID: cc:40:d0:15:4a:3b
[NETAPP EVENT] IP acquired by the device

Device has connected to xxxxxxx
Device IP Address is 192.168.1.48

6 3304 [Tmr Svc] Wi-Fi connected to AP xxxxxx.
7 3305 [Tmr Svc] IP Address acquired 192.168.1.48
8 3308 [Tmr Svc] Security alert threshold = 15
9 3308 [Tmr Svc] Current number of alerts = 0
10 3308 [Tmr Svc] Creating MQTT Echo Task…
11 3309 [MQTTEcho] MQTT echo attempting to connect to xxxxxxxxxx-ats.iot.ap-northeast-1.amazonaws.com.
15 6211 [MQTTEcho] MQTT echo connected.
16 6211 [MQTTEcho] MQTT echo test echoing task created.
18 6614 [MQTTEcho] MQTT Echo demo subscribed to freertos/demos/echo
20 7018 [MQTTEcho] Echo successfully published ‘Hello World 0’
22 7222 [Echoing] Message returned with ACK: ‘Hello World 0 ACK’

Are you missing any of the steps above ?

lph65724 wrote on April 17, 2019:

Hi ravishankar-AWS,

Hmm, that is very strange. I did exactly the same procedures several times, but I never got it to work. Actually, I have also tried with ST and Espressif boards, and they both work fine. I wonder, besides downloading the service pack, if I need to configure CC3220 prior to downloading echo sample code.

Thank you

qiutongs wrote on July 12, 2019:

Is it still an issue? We have a new release recently that you might want to try.

https://github.com/aws/amazon-freertos/tree/201906.00_Major