无法使用嵌入式 C SDK 连接 AWS 主机 url

Unable to connect with AWS host url using Embedded C SDK

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

如有错误请告知。

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

错误:连接到 215740087218.iot.ap-south-1.amazonaws.com:8883

的主 L#190 错误 (-23)
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
// =================================================

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

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# 

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

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):

#define MBEDTLS_ERR_NET_UNKNOWN_HOST                      -0x0052  /**< Failed to get an IP address for the given hostname. */

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