首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >向AWS IOT Shadows发送数据ESP8266时出现“无法设置尝试发送数据的SSL连接”错误消息

向AWS IOT Shadows发送数据ESP8266时出现“无法设置尝试发送数据的SSL连接”错误消息
EN

Stack Overflow用户
提问于 2019-01-29 07:48:47
回答 2查看 1.6K关注 0票数 1

我正在尝试发送一个测试值到AWS IOT Shadows,但是当我将它上传到我的设备时,它总是说"Cant Setup SSL ConnectionTrying to send Data“。请帮助我将此值发送给AWS IOT Shaodws!我已尝试将ARN更改为HTTPS端点ARN。并不断收到此错误消息。

代码语言:javascript
复制
#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);
}

继续收到此错误消息。

代码语言:javascript
复制
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

请帮帮我!谢谢

EN

回答 2

Stack Overflow用户

发布于 2019-01-29 09:20:35

setAWSDomain()需要API终结点,而不是ARN。

Here is an example

要查找API端点,请在控制台中选择设备,方法是进入IoT > Manage > Things > ThingName > Interact并找到HTTPS端点。

或者,您可以从AWS CLI使用describe-endpoint命令。

票数 1
EN

Stack Overflow用户

发布于 2019-02-20 16:10:32

如上所述,需要使用您的端点更新以下行:

代码语言:javascript
复制
From:
iotClient.setAWSDomain("arn:aws:iot:ap-southeast-2:489747887701:thing/IoTTestDevice");

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

即使解决了这个问题,并假设您的esp8266主板版本大于2.3.0和低于2.6.0,您可能仍然会遇到相同的问题:-(

FWIW,esp8266 2.3.0主板版本将连接到aws iot,但应用程序崩溃出现了不同的问题(参考:https://github.com/esp8266/Arduino/issues/4811)。我还没能找到一个解决方案...还有谁成功了吗?

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/54411947

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档