ESP32-C3 Supermini AWS IOT CORE integration Issue!

I have Flashed the Program successfully to my ESP32-C3 Supermini module. The following error requires your kind attention and solution

I (2273528) coreMQTT: An MQTT session with broker is re-established. Resending unacked publishes.
I (2273538) coreMQTT: Subscribing to the MQTT topic /example/topic.
I (2273548) coreMQTT: SUBSCRIBE sent for topic /example/topic to broker.


E (2273728) coreMQTT: Call to receiveSingleIteration failed. Status=MQTTRecvFailed
E (2273728) coreMQTT: MQTT_ProcessLoop failed to receive ACK packet: Expected ACK Packet ID=121, LoopDuration=181, Status=MQTTRecvFailed
I (2273738) coreMQTT: Disconnecting the MQTT connection with a2ymunmj15xks7-ats.iot.ap-south-1.amazonaws.com.
I (2273748) coreMQTT: Disconnected from the broker.
I (2273758) coreMQTT: Short delay before starting the next iteration....

I (2278768) coreMQTT: Establishing a TLS session to a2ymj15xks7-ats.iot.ap-south-1.amazonaws.com:8883.
I (2281608) coreMQTT: MQTT connection established with the broker.
I (2281608) coreMQTT: MQTT connection successfully established with broker.

Is this because of the mis configured IOT policy or Something else. I think the error log is coming from this part of the code as follows :

static int waitForPacketAck( MQTTContext_t * pMqttContext,
                             uint16_t usPacketIdentifier,
                             uint32_t ulTimeout )
{
    uint32_t ulMqttProcessLoopEntryTime;
    uint32_t ulMqttProcessLoopTimeoutTime;
    uint32_t ulCurrentTime;

    MQTTStatus_t eMqttStatus = MQTTSuccess;
    int returnStatus = EXIT_FAILURE;

    /* Reset the ACK packet identifier being received. */
    globalAckPacketIdentifier = 0U;

    ulCurrentTime = pMqttContext->getTime();
    ulMqttProcessLoopEntryTime = ulCurrentTime;
    ulMqttProcessLoopTimeoutTime = ulCurrentTime + ulTimeout;

    /* Call MQTT_ProcessLoop multiple times until the expected packet ACK
     * is received, a timeout happens, or MQTT_ProcessLoop fails. */
    while( ( globalAckPacketIdentifier != usPacketIdentifier ) &&
           ( ulCurrentTime < ulMqttProcessLoopTimeoutTime ) &&
           ( eMqttStatus == MQTTSuccess || eMqttStatus == MQTTNeedMoreBytes ) )
    {
        /* Event callback will set #globalAckPacketIdentifier when receiving
         * appropriate packet. */
        eMqttStatus = MQTT_ProcessLoop( pMqttContext );
        ulCurrentTime = pMqttContext->getTime();
    }

    if( ( ( eMqttStatus != MQTTSuccess ) && ( eMqttStatus != MQTTNeedMoreBytes ) ) ||
        ( globalAckPacketIdentifier != usPacketIdentifier ) )
    {
        LogError( ( "MQTT_ProcessLoop failed to receive ACK packet: Expected ACK Packet ID=%02"PRIx16", LoopDuration=%"PRIu32", Status=%s",
                    usPacketIdentifier,
                    ( ulCurrentTime - ulMqttProcessLoopEntryTime ),
                    MQTT_Status_strerror( eMqttStatus ) ) );
    }
    else
    {
        returnStatus = EXIT_SUCCESS;
    }

    return returnStatus;
}

/*-----------------------------------------------------------*/

static MQTTStatus_t processLoopWithTimeout( MQTTContext_t * pMqttContext,
                                            uint32_t ulTimeoutMs )
{
    uint32_t ulMqttProcessLoopTimeoutTime;
    uint32_t ulCurrentTime;

    MQTTStatus_t eMqttStatus = MQTTSuccess;

    ulCurrentTime = pMqttContext->getTime();
    ulMqttProcessLoopTimeoutTime = ulCurrentTime + ulTimeoutMs;

    /* Call MQTT_ProcessLoop multiple times a timeout happens, or
     * MQTT_ProcessLoop fails. */
    while( ( ulCurrentTime < ulMqttProcessLoopTimeoutTime ) &&
           ( eMqttStatus == MQTTSuccess || eMqttStatus == MQTTNeedMoreBytes ) )
    {
        eMqttStatus = MQTT_ProcessLoop( pMqttContext );
        ulCurrentTime = pMqttContext->getTime();
    }

    return eMqttStatus;
} 

To add more, this code should send a string message " Device Connected!", when i subscribe to the “/example/topic” I don’t see any messages. kindly advice what to do to resolve this issue?

E (2273728) coreMQTT: Call to receiveSingleIteration failed. Status=MQTTRecvFailed
The code that this problem is generating from:
static MQTTStatus_t receiveSingleIteration(MQTTContext_t pContext,
                                                                         uint32_t remainingTimeMS,
                                                                        bool manageKeepAlive)

The returns is MQTTRecvFailed. As it is explained in the document reads like – if a network error occurs during reception; But How to solve this issue. where to look, is it the server side of the problem meaning mis configuring policy?

Hi @MahadiHasanTauhid
Welcome to the FreeRTOS Community Forums !
Looking at the logs , the configuration sets a timeout but when the code reaches that timeout, instead of retrying, the code simply fails. Could you let us know the source of this code?

If there is timeout, you should try increasing the timeout value and see if the code works

Hello @karahulx ,
thank you for your kind reply. I am sharing the code link that I 'm currently working on. Link : ESP AWS IOT Mqtt/Mutual Auth example. mqtt_demo_mutual_auth.c is the source code for setting all parameters for the example.

I think you are referring to some time frame set in the configuration like below, which I found in the code:

Source: https://github.com/espressif/esp-aws-iot/blob/master/examples/mqtt/tls_mutual_auth/main/mqtt_demo_mutual_auth.c

#define MQTT_PROCESS_LOOP_TIMEOUT_MS        ( 5000U )

/**
 * @brief The maximum time interval in seconds which is allowed to elapse
 *  between two Control Packets.
 *
 *  It is the responsibility of the Client to ensure that the interval between
 *  Control Packets being sent does not exceed the this Keep Alive value. In the
 *  absence of sending any other Control Packets, the Client MUST send a
 *  PINGREQ Packet.
 */
#define MQTT_KEEP_ALIVE_INTERVAL_SECONDS    ( 60U )

/**
 * @brief Delay between MQTT publishes in seconds.
 */
#define DELAY_BETWEEN_PUBLISHES_SECONDS     ( 1U )

/**
 * @brief Number of PUBLISH messages sent per iteration.
 */
#define MQTT_PUBLISH_COUNT_PER_LOOP         ( 5U )

/**
 * @brief Delay in seconds between two iterations of subscribePublishLoop().
 */
#define MQTT_SUBPUB_LOOP_DELAY_SECONDS      ( 5U )

/**
 * @brief Transport timeout in milliseconds for transport send and receive.
 */
#define TRANSPORT_SEND_RECV_TIMEOUT_MS      ( 1500U )

Thanks in Advance.

Try increasing this value:

#define TRANSPORT_SEND_RECV_TIMEOUT_MS      ( 10000U )

Also, share your policy document as you suspect it to be wrong.

@aggarg

|Allow|iot:Connect|arn:aws:iot:ap-south-1:965678173xxx:client/clientid|
|---|---|---|
|Allow|iot:Subscribe|arn:aws:iot:ap-south-1:xxx:topicfilter/example/topic|
|Allow|iot:Receive|arn:aws:iot:ap-south-1:xxx:topic/example/topic|
|Allow|iot:Publish|arn:aws:iot:ap-south-1:xxx:topic/example/topic|

I have tried changing the time but with no effect. The error is same as before. shared the iot policy above. ( just replaced several numbers by “xxx” for discussion only)

Just for testing can you change the policy to allow all the iot actions from all clients. Something like this -

|Allow|iot:*|*|

Note that this is only to ensure that policy is not an issue. DO NOT do this in production.

If it does not work, the next step would be to capture network traffic using Wireshark.

@aggarg
I checked my IOT core console on activity section things>activity where the “disconnectReasons” is marked as “Client_ERROR
https://docs.aws.amazon.com/iot/latest/developerguide/life-cycle-events.html
the document read as:
The client did something wrong that causes it to disconnect. For example, a client will be disconnected for sending more than 1 MQTT CONNECT packet on the same connection or if the client attempts to publish with a payload that exceeds the payload limit.

Thank you for finding that. We need figure out what unexpected thing the client is doing. Are you using the code as it is or did you make any changes? Is it possible for you to capture network traffic?

@aggarg
I changed the code a little to enable the Bluetooth feature of my ESP32C3 which is working as it should. The rest of the code remains the same. I will try to capture the network traffic using wireshark and share.

@aggarg
I’m not too familiar with the wireshark and capture analyzing.
The wireshark capture below:


No.     Time           Source                Destination           Protocol Length Info
      4 4.649020       Espressif_bd:dd:f4    Broadcast             ARP      42     ARP Announcement for 192.168.1.106

Frame 4: 42 bytes on wire (336 bits), 42 bytes captured (336 bits) on interface \Device\NPF_{E5528078-2972-445B-996B-F473A0F2113D}, id 0
Ethernet II, Src: Espressif_bd:dd:f4 (ec:da:3b:bd:dd:f4), Dst: Broadcast (ff:ff:ff:ff:ff:ff)
Address Resolution Protocol (ARP Announcement)

No.     Time           Source                Destination           Protocol Length Info
      5 4.689387       192.168.1.103         255.255.255.255       UDP      82     49665 → 1947 Len=40

Frame 5: 82 bytes on wire (656 bits), 82 bytes captured (656 bits) on interface \Device\NPF_{E5528078-2972-445B-996B-F473A0F2113D}, id 0
Ethernet II, Src: CloudNetwork_b3:79:5b (f8:89:d2:b3:79:5b), Dst: Broadcast (ff:ff:ff:ff:ff:ff)
Internet Protocol Version 4, Src: 192.168.1.103, Dst: 255.255.255.255
User Datagram Protocol, Src Port: 49665, Dst Port: 1947
Data (40 bytes)

0000  78 63 31 7a 6a 53 38 6b 35 45 45 71 54 4d 62 75   xc1zjS8k5EEqTMbu
0010  41 42 44 39 78 2b 34 2b 6c 4b 4a 4f 47 49 37 6e   ABD9x+4+lKJOGI7n
0020  55 71 32 45 59 6e 38 41                           Uq2EYn8A

No.     Time           Source                Destination           Protocol Length Info
      6 5.081994       192.168.1.103         231.1.1.1             UDP      90     4445 → 4446 Len=48

Frame 6: 90 bytes on wire (720 bits), 90 bytes captured (720 bits) on interface \Device\NPF_{E5528078-2972-445B-996B-F473A0F2113D}, id 0
Ethernet II, Src: CloudNetwork_b3:79:5b (f8:89:d2:b3:79:5b), Dst: IPv4mcast_01:01:01 (01:00:5e:01:01:01)
Internet Protocol Version 4, Src: 192.168.1.103, Dst: 231.1.1.1
User Datagram Protocol, Src Port: 4445, Dst Port: 4446
Data (48 bytes)

0000  31 39 32 2e 31 36 38 2e 31 2e 31 30 33 3a 38 30   192.168.1.103:80
0010  38 38 6d 61 69 6e 3b 49 67 6e 69 74 69 6f 6e 2d   88main;Ignition-
0020  44 45 53 4b 54 4f 50 2d 51 30 50 43 41 33 43 3b   DESKTOP-Q0PCA3C;

No.     Time           Source                Destination           Protocol Length Info
      7 8.719851       192.168.1.103         192.168.1.255         UDP      82     49665 → 1947 Len=40

Frame 7: 82 bytes on wire (656 bits), 82 bytes captured (656 bits) on interface \Device\NPF_{E5528078-2972-445B-996B-F473A0F2113D}, id 0
Ethernet II, Src: CloudNetwork_b3:79:5b (f8:89:d2:b3:79:5b), Dst: Broadcast (ff:ff:ff:ff:ff:ff)
Internet Protocol Version 4, Src: 192.168.1.103, Dst: 192.168.1.255
User Datagram Protocol, Src Port: 49665, Dst Port: 1947
Data (40 bytes)

0000  78 63 31 7a 6a 53 38 6b 35 45 45 71 54 4d 62 75   xc1zjS8k5EEqTMbu
0010  41 42 44 39 78 2b 34 2b 6c 4b 4a 4f 47 49 37 6e   ABD9x+4+lKJOGI7n
0020  55 71 32 45 59 6e 38 41                           Uq2EYn8A

No.     Time           Source                Destination           Protocol Length Info
      8 9.151540       zte_21:f2:fc          CloudNetwork_b3:79:5b ARP      42     Who has 192.168.1.103? Tell 192.168.1.1

Frame 8: 42 bytes on wire (336 bits), 42 bytes captured (336 bits) on interface \Device\NPF_{E5528078-2972-445B-996B-F473A0F2113D}, id 0
Ethernet II, Src: zte_21:f2:fc (98:00:6a:21:f2:fc), Dst: CloudNetwork_b3:79:5b (f8:89:d2:b3:79:5b)
Address Resolution Protocol (request)

No.     Time           Source                Destination           Protocol Length Info
      9 9.151569       CloudNetwork_b3:79:5b zte_21:f2:fc          ARP      42     192.168.1.103 is at f8:89:d2:b3:79:5b

Frame 9: 42 bytes on wire (336 bits), 42 bytes captured (336 bits) on interface \Device\NPF_{E5528078-2972-445B-996B-F473A0F2113D}, id 0
Ethernet II, Src: CloudNetwork_b3:79:5b (f8:89:d2:b3:79:5b), Dst: zte_21:f2:fc (98:00:6a:21:f2:fc)
Address Resolution Protocol (reply)

No.     Time           Source                Destination           Protocol Length Info
     10 9.671162       192.168.1.103         23.97.226.21          TCP      66     63299 → 443 [SYN] Seq=0 Win=64240 Len=0 MSS=1460 WS=256 SACK_PERM

Frame 10: 66 bytes on wire (528 bits), 66 bytes captured (528 bits) on interface \Device\NPF_{E5528078-2972-445B-996B-F473A0F2113D}, id 0
Ethernet II, Src: CloudNetwork_b3:79:5b (f8:89:d2:b3:79:5b), Dst: zte_21:f2:fc (98:00:6a:21:f2:fc)
Internet Protocol Version 4, Src: 192.168.1.103, Dst: 23.97.226.21
Transmission Control Protocol, Src Port: 63299, Dst Port: 443, Seq: 0, Len: 0

No.     Time           Source                Destination           Protocol Length Info
     11 9.870794       23.97.226.21          192.168.1.103         TCP      66     443 → 63299 [SYN, ACK] Seq=0 Ack=1 Win=65535 Len=0 MSS=1440 WS=256 SACK_PERM

Frame 11: 66 bytes on wire (528 bits), 66 bytes captured (528 bits) on interface \Device\NPF_{E5528078-2972-445B-996B-F473A0F2113D}, id 0
Ethernet II, Src: zte_21:f2:fc (98:00:6a:21:f2:fc), Dst: CloudNetwork_b3:79:5b (f8:89:d2:b3:79:5b)
Internet Protocol Version 4, Src: 23.97.226.21, Dst: 192.168.1.103
Transmission Control Protocol, Src Port: 443, Dst Port: 63299, Seq: 0, Ack: 1, Len: 0

No.     Time           Source                Destination           Protocol Length Info
     12 9.870894       192.168.1.103         23.97.226.21          TCP      54     63299 → 443 [ACK] Seq=1 Ack=1 Win=132352 Len=0

Frame 12: 54 bytes on wire (432 bits), 54 bytes captured (432 bits) on interface \Device\NPF_{E5528078-2972-445B-996B-F473A0F2113D}, id 0
Ethernet II, Src: CloudNetwork_b3:79:5b (f8:89:d2:b3:79:5b), Dst: zte_21:f2:fc (98:00:6a:21:f2:fc)
Internet Protocol Version 4, Src: 192.168.1.103, Dst: 23.97.226.21
Transmission Control Protocol, Src Port: 63299, Dst Port: 443, Seq: 1, Ack: 1, Len: 0

No.     Time           Source                Destination           Protocol Length Info
     13 9.872246       192.168.1.103         23.97.226.21          TLSv1.3  436    Client Hello (SNI=ewm-ingestion.servicebus.windows.net)

Frame 13: 436 bytes on wire (3488 bits), 436 bytes captured (3488 bits) on interface \Device\NPF_{E5528078-2972-445B-996B-F473A0F2113D}, id 0
Ethernet II, Src: CloudNetwork_b3:79:5b (f8:89:d2:b3:79:5b), Dst: zte_21:f2:fc (98:00:6a:21:f2:fc)
Internet Protocol Version 4, Src: 192.168.1.103, Dst: 23.97.226.21
Transmission Control Protocol, Src Port: 63299, Dst Port: 443, Seq: 1, Ack: 1, Len: 382
Transport Layer Security

No.     Time           Source                Destination           Protocol Length Info
     14 10.067544      23.97.226.21          192.168.1.103         TLSv1.3  153    Hello Retry Request, Change Cipher Spec

Frame 14: 153 bytes on wire (1224 bits), 153 bytes captured (1224 bits) on interface \Device\NPF_{E5528078-2972-445B-996B-F473A0F2113D}, id 0
Ethernet II, Src: zte_21:f2:fc (98:00:6a:21:f2:fc), Dst: CloudNetwork_b3:79:5b (f8:89:d2:b3:79:5b)
Internet Protocol Version 4, Src: 23.97.226.21, Dst: 192.168.1.103
Transmission Control Protocol, Src Port: 443, Dst Port: 63299, Seq: 1, Ack: 383, Len: 99
Transport Layer Security

No.     Time           Source                Destination           Protocol Length Info
     15 10.071118      192.168.1.103         23.97.226.21          TLSv1.3  507    Change Cipher Spec, Client Hello (SNI=ewm-ingestion.servicebus.windows.net)

Frame 15: 507 bytes on wire (4056 bits), 507 bytes captured (4056 bits) on interface \Device\NPF_{E5528078-2972-445B-996B-F473A0F2113D}, id 0
Ethernet II, Src: CloudNetwork_b3:79:5b (f8:89:d2:b3:79:5b), Dst: zte_21:f2:fc (98:00:6a:21:f2:fc)
Internet Protocol Version 4, Src: 192.168.1.103, Dst: 23.97.226.21
Transmission Control Protocol, Src Port: 63299, Dst Port: 443, Seq: 383, Ack: 100, Len: 453
Transport Layer Security

No.     Time           Source                Destination           Protocol Length Info
     16 10.167560      192.168.1.103         231.1.1.1             UDP      90     4445 → 4446 Len=48

Frame 16: 90 bytes on wire (720 bits), 90 bytes captured (720 bits) on interface \Device\NPF_{E5528078-2972-445B-996B-F473A0F2113D}, id 0
Ethernet II, Src: CloudNetwork_b3:79:5b (f8:89:d2:b3:79:5b), Dst: IPv4mcast_01:01:01 (01:00:5e:01:01:01)
Internet Protocol Version 4, Src: 192.168.1.103, Dst: 231.1.1.1
User Datagram Protocol, Src Port: 4445, Dst Port: 4446
Data (48 bytes)

0000  31 39 32 2e 31 36 38 2e 31 2e 31 30 33 3a 38 30   192.168.1.103:80
0010  38 38 6d 61 69 6e 3b 49 67 6e 69 74 69 6f 6e 2d   88main;Ignition-
0020  44 45 53 4b 54 4f 50 2d 51 30 50 43 41 33 43 3b   DESKTOP-Q0PCA3C;

No.     Time           Source                Destination           Protocol Length Info
     17 10.269487      23.97.226.21          192.168.1.103         TLSv1.3  1506   Server Hello

Frame 17: 1506 bytes on wire (12048 bits), 1506 bytes captured (12048 bits) on interface \Device\NPF_{E5528078-2972-445B-996B-F473A0F2113D}, id 0
Ethernet II, Src: zte_21:f2:fc (98:00:6a:21:f2:fc), Dst: CloudNetwork_b3:79:5b (f8:89:d2:b3:79:5b)
Internet Protocol Version 4, Src: 23.97.226.21, Dst: 192.168.1.103
Transmission Control Protocol, Src Port: 443, Dst Port: 63299, Seq: 100, Ack: 836, Len: 1452
Transport Layer Security

No.     Time           Source                Destination           Protocol Length Info
     18 10.269487      23.97.226.21          192.168.1.103         TCP      1506   443 → 63299 [ACK] Seq=1552 Ack=836 Win=4193792 Len=1452 [TCP segment of a reassembled PDU]

Frame 18: 1506 bytes on wire (12048 bits), 1506 bytes captured (12048 bits) on interface \Device\NPF_{E5528078-2972-445B-996B-F473A0F2113D}, id 0
Ethernet II, Src: zte_21:f2:fc (98:00:6a:21:f2:fc), Dst: CloudNetwork_b3:79:5b (f8:89:d2:b3:79:5b)
Internet Protocol Version 4, Src: 23.97.226.21, Dst: 192.168.1.103
Transmission Control Protocol, Src Port: 443, Dst Port: 63299, Seq: 1552, Ack: 836, Len: 1452

No.     Time           Source                Destination           Protocol Length Info
     19 10.269594      192.168.1.103         23.97.226.21          TCP      54     63299 → 443 [ACK] Seq=836 Ack=3004 Win=132352 Len=0

Frame 19: 54 bytes on wire (432 bits), 54 bytes captured (432 bits) on interface \Device\NPF_{E5528078-2972-445B-996B-F473A0F2113D}, id 0
Ethernet II, Src: CloudNetwork_b3:79:5b (f8:89:d2:b3:79:5b), Dst: zte_21:f2:fc (98:00:6a:21:f2:fc)
Internet Protocol Version 4, Src: 192.168.1.103, Dst: 23.97.226.21
Transmission Control Protocol, Src Port: 63299, Dst Port: 443, Seq: 836, Ack: 3004, Len: 0

No.     Time           Source                Destination           Protocol Length Info
     20 10.271350      23.97.226.21          192.168.1.103         TLSv1.3  1350   Application Data

Frame 20: 1350 bytes on wire (10800 bits), 1350 bytes captured (10800 bits) on interface \Device\NPF_{E5528078-2972-445B-996B-F473A0F2113D}, id 0
Ethernet II, Src: zte_21:f2:fc (98:00:6a:21:f2:fc), Dst: CloudNetwork_b3:79:5b (f8:89:d2:b3:79:5b)
Internet Protocol Version 4, Src: 23.97.226.21, Dst: 192.168.1.103
Transmission Control Protocol, Src Port: 443, Dst Port: 63299, Seq: 3004, Ack: 836, Len: 1296
[3 Reassembled TCP Segments (4008 bytes): #17(1260), #18(1452), #20(1296)]
Transport Layer Security

No.     Time           Source                Destination           Protocol Length Info
     21 10.275038      192.168.1.103         23.97.226.21          TLSv1.3  235    Application Data, Application Data

Frame 21: 235 bytes on wire (1880 bits), 235 bytes captured (1880 bits) on interface \Device\NPF_{E5528078-2972-445B-996B-F473A0F2113D}, id 0
Ethernet II, Src: CloudNetwork_b3:79:5b (f8:89:d2:b3:79:5b), Dst: zte_21:f2:fc (98:00:6a:21:f2:fc)
Internet Protocol Version 4, Src: 192.168.1.103, Dst: 23.97.226.21
Transmission Control Protocol, Src Port: 63299, Dst Port: 443, Seq: 836, Ack: 4300, Len: 181
Transport Layer Security

No.     Time           Source                Destination           Protocol Length Info
     22 10.324459      192.168.1.101         224.0.0.251           MDNS     152    Standard query 0x0025 PTR _%9E5E7C8F47989526C9BCD95D24084F6F0B27C5ED._sub._googlecast._tcp.local, "QM" question PTR _CFE7FEDA._sub._googlecast._tcp.local, "QM" question PTR _googlecast._tcp.local, "QM" question

Frame 22: 152 bytes on wire (1216 bits), 152 bytes captured (1216 bits) on interface \Device\NPF_{E5528078-2972-445B-996B-F473A0F2113D}, id 0
Ethernet II, Src: 7a:72:43:51:04:73 (7a:72:43:51:04:73), Dst: CloudNetwork_b3:79:5b (f8:89:d2:b3:79:5b)
Internet Protocol Version 4, Src: 192.168.1.101, Dst: 224.0.0.251
User Datagram Protocol, Src Port: 5353, Dst Port: 5353
Multicast Domain Name System (query)

No.     Time           Source                Destination           Protocol Length Info
     23 10.469490      23.97.226.21          192.168.1.103         TLSv1.3  157    Application Data

Frame 23: 157 bytes on wire (1256 bits), 157 bytes captured (1256 bits) on interface \Device\NPF_{E5528078-2972-445B-996B-F473A0F2113D}, id 0
Ethernet II, Src: zte_21:f2:fc (98:00:6a:21:f2:fc), Dst: CloudNetwork_b3:79:5b (f8:89:d2:b3:79:5b)
Internet Protocol Version 4, Src: 23.97.226.21, Dst: 192.168.1.103
Transmission Control Protocol, Src Port: 443, Dst Port: 63299, Seq: 4300, Ack: 1017, Len: 103
Transport Layer Security

No.     Time           Source                Destination           Protocol Length Info
     24 10.510207      192.168.1.103         23.97.226.21          TCP      54     63299 → 443 [ACK] Seq=1017 Ack=4403 Win=131072 Len=0

Frame 24: 54 bytes on wire (432 bits), 54 bytes captured (432 bits) on interface \Device\NPF_{E5528078-2972-445B-996B-F473A0F2113D}, id 0
Ethernet II, Src: CloudNetwork_b3:79:5b (f8:89:d2:b3:79:5b), Dst: zte_21:f2:fc (98:00:6a:21:f2:fc)
Internet Protocol Version 4, Src: 192.168.1.103, Dst: 23.97.226.21
Transmission Control Protocol, Src Port: 63299, Dst Port: 443, Seq: 1017, Ack: 4403, Len: 0

No.     Time           Source                Destination           Protocol Length Info
     25 10.872943      23.97.226.21          192.168.1.103         TLSv1.3  1007   Application Data

Frame 25: 1007 bytes on wire (8056 bits), 1007 bytes captured (8056 bits) on interface \Device\NPF_{E5528078-2972-445B-996B-F473A0F2113D}, id 0
Ethernet II, Src: zte_21:f2:fc (98:00:6a:21:f2:fc), Dst: CloudNetwork_b3:79:5b (f8:89:d2:b3:79:5b)
Internet Protocol Version 4, Src: 23.97.226.21, Dst: 192.168.1.103
Transmission Control Protocol, Src Port: 443, Dst Port: 63299, Seq: 4403, Ack: 1017, Len: 953
Transport Layer Security

No.     Time           Source                Destination           Protocol Length Info
     26 10.872943      23.97.226.21          192.168.1.103         TLSv1.3  81     Application Data

Frame 26: 81 bytes on wire (648 bits), 81 bytes captured (648 bits) on interface \Device\NPF_{E5528078-2972-445B-996B-F473A0F2113D}, id 0
Ethernet II, Src: zte_21:f2:fc (98:00:6a:21:f2:fc), Dst: CloudNetwork_b3:79:5b (f8:89:d2:b3:79:5b)
Internet Protocol Version 4, Src: 23.97.226.21, Dst: 192.168.1.103
Transmission Control Protocol, Src Port: 443, Dst Port: 63299, Seq: 5356, Ack: 1017, Len: 27
Transport Layer Security

No.     Time           Source                Destination           Protocol Length Info
     27 10.873047      192.168.1.103         23.97.226.21          TCP      54     63299 → 443 [ACK] Seq=1017 Ack=5383 Win=132352 Len=0

Frame 27: 54 bytes on wire (432 bits), 54 bytes captured (432 bits) on interface \Device\NPF_{E5528078-2972-445B-996B-F473A0F2113D}, id 0
Ethernet II, Src: CloudNetwork_b3:79:5b (f8:89:d2:b3:79:5b), Dst: zte_21:f2:fc (98:00:6a:21:f2:fc)
Internet Protocol Version 4, Src: 192.168.1.103, Dst: 23.97.226.21
Transmission Control Protocol, Src Port: 63299, Dst Port: 443, Seq: 1017, Ack: 5383, Len: 0

No.     Time           Source                Destination           Protocol Length Info
     28 10.873936      192.168.1.103         23.97.226.21          TCP      54     63299 → 443 [FIN, ACK] Seq=1017 Ack=5383 Win=132352 Len=0

Frame 28: 54 bytes on wire (432 bits), 54 bytes captured (432 bits) on interface \Device\NPF_{E5528078-2972-445B-996B-F473A0F2113D}, id 0
Ethernet II, Src: CloudNetwork_b3:79:5b (f8:89:d2:b3:79:5b), Dst: zte_21:f2:fc (98:00:6a:21:f2:fc)
Internet Protocol Version 4, Src: 192.168.1.103, Dst: 23.97.226.21
Transmission Control Protocol, Src Port: 63299, Dst Port: 443, Seq: 1017, Ack: 5383, Len: 0

No.     Time           Source                Destination           Protocol Length Info
     29 11.069341      23.97.226.21          192.168.1.103         TCP      54     443 → 63299 [FIN, ACK] Seq=5383 Ack=1018 Win=4193792 Len=0

Frame 29: 54 bytes on wire (432 bits), 54 bytes captured (432 bits) on interface \Device\NPF_{E5528078-2972-445B-996B-F473A0F2113D}, id 0
Ethernet II, Src: zte_21:f2:fc (98:00:6a:21:f2:fc), Dst: CloudNetwork_b3:79:5b (f8:89:d2:b3:79:5b)
Internet Protocol Version 4, Src: 23.97.226.21, Dst: 192.168.1.103
Transmission Control Protocol, Src Port: 443, Dst Port: 63299, Seq: 5383, Ack: 1018, Len: 0

No.     Time           Source                Destination           Protocol Length Info
     30 11.069409      192.168.1.103         23.97.226.21          TCP      54     63299 → 443 [ACK] Seq=1018 Ack=5384 Win=132352 Len=0

Frame 30: 54 bytes on wire (432 bits), 54 bytes captured (432 bits) on interface \Device\NPF_{E5528078-2972-445B-996B-F473A0F2113D}, id 0
Ethernet II, Src: CloudNetwork_b3:79:5b (f8:89:d2:b3:79:5b), Dst: zte_21:f2:fc (98:00:6a:21:f2:fc)
Internet Protocol Version 4, Src: 192.168.1.103, Dst: 23.97.226.21
Transmission Control Protocol, Src Port: 63299, Dst Port: 443, Seq: 1018, Ack: 5384, Len: 0

Better attach a wireshark capture file (pcap file).
This can be easily loaded by @aggarg and analyzed in detail.

I don’t think you can directly attach the capture file using the upload option here in the forum. @hs2 . I tried but I don’t see it working. so I’m sharing via google drive link below.

https://drive.google.com/file/d/1A5oh5DQpHZA4-W-IMQRDa05m30GpADaw/view?usp=sharing

Is the IP address of your device in this capture 192.168.1.103? If yes, the device seems to be initiating the disconnect:

Can you try to find out why the device is closing the connection?

@aggarg
The ip address for the ESP32C3 device is 192.168.1.106 and the ip for the pc is 192.168.1.103

That is a bit strange. Why is PC trying to establish a connection with AWS IoT Core? I do not see any trace for ip 192.168.1.106.

@aggarg

In the previous comment where i shared the plain text format of the wireshark capture, I see the protocol is ARP for the ESP32C3 Device? Is it normal as well?

Yes, that is normal. I think we need to find out who is closing the connection and why.

@aggarg
I tried to find out the reason but not sure what causing the pc initiating AWS iot connection on its own. But the pc has several installed SCADA software, the name of the pc is indicative that one the SCADA software Ignition is trying to get in the way. but why and how still beyond me. I filtered for mqtt port 8883 but I see nothing related to that port only port 443 —used tcp.port == 8883 or tcp.port == 443.

It may not be an issue as the AWS IoT supports both 8883 and 443. Please check the client code and see port it is using.