I am trying to run the coreMQTT Demo (Mutual Authentication), following the configuration as described on MQTT Demo (with TLS – Mutual Authentication) - FreeRTOS, but this demo is not running properly and the log is shown below. Can anyone suggest what can be the possible ways to fix this?
The interface that will be opened is set by "configNETWORK_INTERFACE_TO_USE", which
should be defined in FreeRTOSConfig.h
Attempting to open interface number 2.
Successfully opened interface number 2.
3 3415 [IP-Task] prvInitialiseDHCP: start after 250 ticks
vDHCPProcess: discover
4 4674 [IP-Task] vDHCPProcess: offer 10.201.99.191
vDHCPProcess: reply 10.201.99.191
5 5134 [IP-Task] vDHCPProcess: offer 10.201.99.191
vDHCPProcess: acked 10.201.99.191
6 5134 [IP-Task]
IP Address: 10.201.99.191
Subnet Mask: 255.255.0.0
7 5134 [IP-Task] Gateway Address: 10.201.0.1
DNS Server Address: 172.19.2.1
8 5415 [DemoTask] [INFO] [MqttMutualAuth] [prvConnectToServerWithBackoffRetries:735] Creating a TLS connection to a2vtd9m5hzbrcl-ats.iot.us-west-2.amazonaws.com:8883.
9 10434 [DemoTask] FreeRTOS_ProcessDNSCache: add: 'a2vtd9m5hzbrcl-ats.iot.us-west-2.amazonaws.com' @ 52.27.62.0 (TTL 60)
DNS[0xD2ED]: The answer to 'a2vtd9m5hzbrcl-ats.iot.us-west-2.amazonaws.com' (52.27.62.0) will be stored
10 10434 [DemoTask] [INFO] [SocketsWrapper] [TCP_Sockets_Connect:135] Creating TCP Connection to a2vtd9m5hzbrcl-ats.iot.us-west-2.amazonaws.com.
11 10434 [DemoTask] FreeRTOS_connect: 2639 to 52.27.62.0:8883
Socket 2639 -> 52.27.62.0:8883 State eCLOSED->eCONNECT_SYN
12 10434 [IP-Task] prvSocketSetMSS: 1400 bytes for 52.27.62.0:8883
prvWinScaleFactor: uxRxWinSize 1 MSS 1400 Factor 0
13 10434 [IP-Task] Connect[52.27.62.0:8883]: next timeout 1: 3000 ms
prvWinScaleFactor: uxRxWinSize 1 MSS 1400 Factor 0
14 13434 [IP-Task] Connect[52.27.62.0:8883]: next timeout 2: 6000 ms
[ERROR] [SocketsWrapper] [TCP_Sockets_Connect:144] 15 15434 [DemoTask] Failed to connect to server: FreeRTOS_Connect failed: ReturnCode=-116, Hostname=a2vtd9m5hzbrcl-ats.iot.us-west-2.amazonaws.com, Port=8883.
16 15434 [IP-Task] FreeRTOS_closesocket[2639 to 52.27.62.0:8883]: buffers 60 socks 0
[ERROR] [MbedtlsTransport] [TLS_FreeRTOS_Connect:678] 17 15434 [DemoTask] Failed to connect to a2vtd9m5hzbrcl-ats.iot.us-west-2.amazonaws.com with error -116.
18 15434 [DemoTask] [WARN] [MqttMutualAuth] [prvConnectToServerWithBackoffRetries:760] Connection to the broker failed. Retrying connection with backoff and jitter.
19 15854 [DemoTask] [INFO] [MqttMutualAuth] [prvConnectToServerWithBackoffRetries:735] Creating a TLS connection to a2vtd9m5hzbrcl-ats.iot.us-west-2.amazonaws.com:8883.
The DNS resolution seems to be working but the TCP connection cannot be established. Do you have a firewall that may be preventing this connection? Can you capture network traffic using wireshark?
I have disabled the firewall on my computer, and then I took a screenshot while capturing packets with Wireshark, and I have also uploaded the packet capture file.
Thank you sharing network capture. As we can see, you do not get any SYNACK for the SYN you send.
It does not have to be a firewall on your computer but a firewall on your network. One possibility is that the firewall does not allow port 8883. You can try port 443 by making the following changes to demo_config.h:
How did you create the device IoT thing? Was it through AWS Command Line Interface (CLI) by running the tools/aws_config_quick_start/SetupAWS.py script. Did it succeed?
Also can you check what is the security policy used in the AWS → IoT Core → Settings
Please make sure the created policy is attached to the thing and at least one version of the policy is active. [AWS IoT → Security → Policies → All versions]
Also, please make sure that your AWS IoT broker is reachable from your region. It seems to be reachable and connecting from where I’m trying:
C:\Users\tonyjosi>ping a2vtd9m5hzbrcl-ats.iot.us-west-2.amazonaws.com
Pinging a2vtd9m5hzbrcl-ats.iot.us-west-2.amazonaws.com [52.34.148.21] with 32 bytes of data:
Reply from 52.34.148.21: bytes=32 time=240ms TTL=243
Reply from 52.34.148.21: bytes=32 time=241ms TTL=243
Reply from 52.34.148.21: bytes=32 time=240ms TTL=243
Reply from 52.34.148.21: bytes=32 time=240ms TTL=243
Ping statistics for 52.34.148.21:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 240ms, Maximum = 241ms, Average = 240ms
C:\Users\tonyjosi>ncat a2vtd9m5hzbrcl-ats.iot.us-west-2.amazonaws.com 8883 -v
Ncat: Version 7.94 ( https://nmap.org/ncat )
Ncat: Connected to 52.34.148.21:8883.
yes, I can ping my AWS IoT broker from my region. And I am trying creating the thing with the AWS Command Line Interface (CLI). But what is the difference between this method and creating the thing by the AWS IoT console?
The version is FreeRTOS 202212.01. I ran the MQTT_Mutual_Auth demo, and I only changed the config file. And this is my demo code. demo_config.zip (6.1 KB)
Thank you for sharing your demo_config. Since it contains your private creds, I’d recommend to remove it and delete the cert from your AWS account later.
Assuming you are using PowerShell, can you run the following command: