首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >无法使用Embedded C SDK与AWS主机url连接

无法使用Embedded C SDK与AWS主机url连接
EN

Stack Overflow用户
提问于 2020-02-11 14:21:58
回答 1查看 297关注 0票数 0

我正在尝试在设备上运行subscribe_publish_sample (ARM架构)。为此,我交叉编译代码并将其复制到设备上。所需的证书也复制到设备。我得到了下面的错误。

如果有任何错误,请让我知道。

错误: iot_tls_connect L#164失败!返回的mbedtls_net_connect -0x52

错误:连接到215740087218.iot.ap-south-1.amazonaws.com:8883时出现主L#190错误(-23)

代码语言:javascript
复制
Configurations : 
#define AWS_IOT_MQTT_HOST              "215740087218.iot.ap-south-1.amazonaws.com" ///< Customer specific MQTT HOST. The same will be used for Thing Shadow
#define AWS_IOT_MQTT_PORT               8883 ///< default port for MQTT/S
#define AWS_IOT_MQTT_CLIENT_ID         "RaspberryPi" ///< MQTT client ID should be unique for every device
#define AWS_IOT_MY_THING_NAME          "RaspberryPi" ///< Thing Name of the Shadow this device is associated with
#define AWS_IOT_ROOT_CA_FILENAME       "rootCA.crt" ///< Root CA file name
#define AWS_IOT_CERTIFICATE_FILENAME   "7256bcd191-certificate.pem.crt" ///< device signed certificate file name
#define AWS_IOT_PRIVATE_KEY_FILENAME   "7256bcd191-private.pem.key" ///< Device private key filename
// =================================================

======================================================================================

代码语言:javascript
复制
Certificates copied to device : 
    root@RelySys:~/aws_iot/my_app/aws-iot-device-sdk-embedded-C-master/certs# ls
    7256bcd191-certificate.pem.crt  7256bcd191-private.pem.key  7256bcd191-public.pem.key  README.txt  rootCA.crt

ARN : arn:aws:iot:ap-south-1:215740087218:thing/RaspberryPi

Policy attached : arn:aws:iot:ap-south-1:215740087218:policy/RaspberrypiPolicy

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": "iot:*",
      "Resource": "*"
    }
  ]
}

==============================================================================
Debug Logs for sample :
root@RelySys:~/aws_iot/my_app/aws-iot-device-sdk-embedded-C-master/samples/linux/subscribe_publish_sample# ./subscribe_publish_sample


AWS IoT SDK Version 3.0.1-

DEBUG:   main L#159 rootCA /home/root/aws_iot/my_app/aws-iot-device-sdk-embedded-C-master/samples/linux/subscribe_publish_sample/../../../certs/rootCA.crt
DEBUG:   main L#160 clientCRT /home/root/aws_iot/my_app/aws-iot-device-sdk-embedded-C-master/samples/linux/subscribe_publish_sample/../../../certs/7256bcd191-certificate.pem.crt
DEBUG:   main L#161 clientKey /home/root/aws_iot/my_app/aws-iot-device-sdk-embedded-C-master/samples/linux/subscribe_publish_sample/../../../certs/7256bcd191-private.pem.key
Connecting...
DEBUG:   iot_tls_connect L#130 
  . Seeding the random number generator...
DEBUG:   iot_tls_connect L#138   . Loading the CA root certificate ...
DEBUG:   iot_tls_connect L#144  ok (0 skipped)

DEBUG:   iot_tls_connect L#146   . Loading the client cert. and key...
DEBUG:   iot_tls_connect L#159  ok

DEBUG:   iot_tls_connect L#161   . Connecting to 215740087218.iot.ap-south-1.amazonaws.com/8883...
ERROR: iot_tls_connect L#164  failed
  ! mbedtls_net_connect returned -0x52


ERROR: main L#190 Error(-23) connecting to 215740087218.iot.ap-south-1.amazonaws.com:8883

telnet logs : 
root@RelySys:~/aws_iot/my_app/aws-iot-device-sdk-embedded-C-master/certs# telnet 215740087218.iot.ap-south-1.amazonaws.com 8883
telnet: bad address '215740087218.iot.ap-south-1.amazonaws.com'
root@RelySys:~/aws_iot/my_app/aws-iot-device-sdk-embedded-C-master/certs# 

 ping response: 
root@RelySys:~/aws_iot/my_app/aws-iot-device-sdk-embedded-C-master/certs# ping 215740087218.iot.ap-south-1.amazonaws.com
ping: bad address '215740087218.iot.ap-south-1.amazonaws.com'
root@RelySys:~/aws_iot/my_app/aws-iot-device-sdk-embedded-C-master/certs# 

Mosquitto_sub response : 

root@RelySys:~/aws_iot/my_app/aws-iot-device-sdk-embedded-C-master/certs# mosquitto_sub --cafile rootCA.crt --cert 7256bcd191-certifi
cate.pem.crt --key 7256bcd191-private.pem.key -h 215740087218.iot.ap-south-1.amazonaws.com -p 8883 -q 0 -d -t sdkTest/sub -i Raspberr
yPi
Unable to connect (Lookup error.).
root@RelySys:~/aws_iot/my_app/aws-iot-device-sdk-embedded-C-master/certs# 
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-02-11 14:31:41

您提供的主机名似乎不正确:

代码语言:javascript
复制
nslookup 215740087218.iot.ap-south-1.amazonaws.com
Server:         127.0.1.1
Address:        127.0.1.1#53

** server can't find 215740087218.iot.ap-south-1.amazonaws.com: NXDOMAIN

错误也证实了这一点(在SDK的net_socket.h中):

代码语言:javascript
复制
#define MBEDTLS_ERR_NET_UNKNOWN_HOST                      -0x0052  /**< Failed to get an IP address for the given hostname. */

阅读AWS IoT Connecting Devices。您需要提供特定于您的帐户的端点。

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

https://stackoverflow.com/questions/60163040

复制
相关文章

相似问题

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