"Can't setup SSL connection Trying to send Data" error message while sending data ESP8266 to AWS IOT Shadows

0

I am trying to send a testing value to AWS IOT Shadows but when I upload it to my device it keep saying "Cant Setup SSL ConnectionTrying to send Data". please help me to send this value to AWS IOT Shaodws! I have tried to change the ARN to HTTPS end point ARN.. and keep getting this error messages.

#include <ESP8266WiFi.h>
#include <AmazonIOTClient.h>
#include <ESP8266AWSImplementations.h>

Esp8266HttpClient httpClient;
Esp8266DateTimeProvider dateTimeProvider;

AmazonIOTClient iotClient;
ActionError actionError;

const char* ssid = "xxx";
const char* password = "xxx";

void initWLAN()
{
  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED)
  {
    delay(500);
  }
}

void initAWS()
{
  iotClient.setAWSRegion("ap-southeast-2");
  iotClient.setAWSEndpoint("amazonaws.com");
  iotClient.setAWSDomain("arn:aws:iot:ap-southeast-2:489747887701:thing/IoTTestDevice");
  iotClient.setAWSPath("/things/IoTTestDevice/shadow");
  iotClient.setAWSKeyID("the-id");
  iotClient.setAWSSecretKey("the-secret-key");
  iotClient.setHttpClient(&httpClient);
  iotClient.setDateTimeProvider(&dateTimeProvider);
}

void setup() {
  Serial.begin(115200);
  delay(10);
  Serial.println("begin");
  initWLAN();
  Serial.println("wlan initialized");
  initAWS();
  Serial.println("iot initialized");
}

void loop()
{
  char shadow[100];
  strcpy(shadow, "{\"state\":{\"reported\":{\"test_value1\":123, \"test_value2\":234}}}");

  Serial.println("Trying to send data");
  Serial.print(shadow);

  char* result = iotClient.update_shadow(shadow, actionError);
  Serial.print(result);

  delay(10000);
}

keep getting this error messages..

12:31:04.295 -> can't setup SSL connectionTrying to send data
12:31:14.262 -> {"state":{"reported":{"test_value1":123, "test_value2":234}}}did not connect to timeserver
12:31:14.564 -> 
12:31:14.564 -> 
12:31:14.564 -> Exception (3):
12:31:14.564 -> epc1=0x4010011d epc2=0x00000000 epc3=0x00000000 excvaddr=0x40008550 depc=0x00000000
12:31:14.564 -> 
12:31:14.564 -> ctx: cont 
12:31:14.564 -> sp: 3ffefd60 end: 3fff0630 offset: 01a0

please help me ! Thanks

amazon-web-services
arduino
iot
esp8266
aws-iot
asked on Stack Overflow Jan 28, 2019 by NamSan Kim • edited Jan 29, 2019 by NamSan Kim

2 Answers

0

setAWSDomain() expects an API endpoint, not an ARN.

Here is an example.

To find the API endpoint, select the device in the console by going to IoT > Manage > Things > ThingName > Interact and find the HTTPS endpoint.

Alternately you can use the describe-endpoint command from the AWS CLI.

answered on Stack Overflow Jan 29, 2019 by bwest
0

As mentioned above, the following line needs to be updated with your endpoint:

From:
iotClient.setAWSDomain("arn:aws:iot:ap-southeast-2:489747887701:thing/IoTTestDevice");

To:
iotClient.setAWSDomain("axxxxxxxxxxxxz-ats.iot.ap-southeast-2.amazonaws.com");

Even after resolving this and assuming your esp8266 board version >2.3.0 and < 2.6.0 you will probably still experience the same problem :-(

FWIW, The esp8266 2.3.0 board version will connect to aws iot, but a different problem occurs with the app crashing (ref: https://github.com/esp8266/Arduino/issues/4811). I haven't been able to find a solution yet... Anyone else had any success?

answered on Stack Overflow Feb 20, 2019 by Doug Inman

User contributions licensed under CC BY-SA 3.0