Skip to content
This repository was archived by the owner on Dec 8, 2022. It is now read-only.
This repository was archived by the owner on Dec 8, 2022. It is now read-only.

[General] Ethernet AWS MQTT DNS Network Error #3544

@Hexagon3626

Description

@Hexagon3626

Briefly summarize the issue being raised
MQTT is unable to connection to AWS endpoint with error occurring at DNS lookup. Similar to issue #936. Error does not occur with the same endpoint link for connection over WiFi.

Describe the desired outcome
Successful MQTT Ethernet connection to AWS endpoint without DNS error. Below shows the intended result using a WiFi module instead of connection over Ethernet:

[AWS WIFI] WINC1500 WIFI: DNS lookup:
Host:       a1c29udxup0qn9-ats.iot.eu-west-1.amazonaws.com
IP Address: 52.213.52.29
[AWS] [INFO ][MQTT][lu] Establishing new MQTT connection.
[AWS] [INFO ][MQTT][lu] (MQTT connection 0x200068e8, CONNECT operation 0x20009bf0) Waiting for operation completion.
[AWS] [INFO ][MQTT][lu] (MQTT connection 0x200068e8, CONNECT operation 0x20009bf0) Wait complete with result SUCCESS.
[AWS] [INFO ][MQTT][lu] New MQTT connection 0x24001ec0 established.

System information

  • Hardware board: STM32H743
  • IDE used: STM32CubeIDE
  • Operating System: Windows
  • Code version: FreeRTOS Kernel V10.2.0
  • Project/Demo: iot_network_afr.c (Amazon FreeRTOS Platform V1.0.0)

References
The below DNS error debug log repeats indefinitely:

[AWS] [ERROR][NET][lu] Failed to resolve a1c29udxup0qn9-ats.iot.eu-west-1.amazon
aws.com.                                                 
[AWS] [ERROR][MQTT][lu] Failed to establish new MQTT connection, error NETWORK E
RROR.                                           
[AWS] [ERROR][DEMO][lu] MQTT CONNECT returned error NETWORK ERROR.
[AWS] [INFO ][Shadow][lu] Shadow library cleanup done.
[AWS] [INFO ][MQTT][lu] MQTT library cleanup done. 
[AWS] [ERROR][DEMO][lu] Error running demo.                 
[IDLE] 133672 104312                                          
[ADMIN] Starting AWS Task                                        
[AWS] [INFO ][DEMO][lu] Successfully initialised the demo. Network type for the 
demo: 4                                                        
[AWS] [INFO ][MQTT][lu] MQTT library successfully initialized.
[AWS] [INFO ][Shadow][lu] Shadow library successfully initialized.

Despite attempts at modifying the link to produce a different result the same DNS server address is always given:
Screenshot (294)

Code to reproduce bug
The following is where the code throws the DNS error within the iot_network_afr.c file:

/* Clear the connection information. */
    ( void ) memset( pNewNetworkConnection, 0x00, sizeof( _networkConnection_t ) );

    /* Create a new TCP socket. */
    tcpSocket = SOCKETS_Socket( SOCKETS_AF_INET,
                                SOCKETS_SOCK_STREAM,
                                SOCKETS_IPPROTO_TCP );

    if( tcpSocket == SOCKETS_INVALID_SOCKET )
    {
        IotLogError( "Failed to create new socket." );
        IOT_SET_AND_GOTO_CLEANUP( IOT_NETWORK_SYSTEM_ERROR );
    }

    /* Set up connection encryption if credentials are provided. */
    if( pAfrCredentials != NULL )
    {
        status = _tlsSetup( pAfrCredentials, tcpSocket, pServerInfo->pHostName, hostnameLength );

        if( status != IOT_NETWORK_SUCCESS )
        {
            IOT_GOTO_CLEANUP();
        }
    }

    /* Establish connection. */
    serverAddress.ucSocketDomain = SOCKETS_AF_INET;
    serverAddress.usPort = SOCKETS_htons( pServerInfo->port );
    serverAddress.ulAddress = SOCKETS_GetHostByName( pServerInfo->pHostName );

    /* Check for errors from DNS lookup. */
    if( serverAddress.ulAddress == 0 )
    {
        IotLogError( "Failed to resolve %s.", pServerInfo->pHostName );
        IOT_SET_AND_GOTO_CLEANUP( IOT_NETWORK_SYSTEM_ERROR );
    }

Steps already taken to overcome issue

  1. As noted in issue 936, modifying values in the FreeRTOSIPConfig.h can resolve the issue but this has not happened. The values I have set below:
#define ipconfigSOCK_DEFAULT_RECEIVE_BLOCK_TIME    pdMS_TO_TICKS( 5000 )
#define ipconfigSOCK_DEFAULT_SEND_BLOCK_TIME       pdMS_TO_TICKS( 5000 )

#define ipconfigUSE_DNS_CACHE                      ( 1 )
#define ipconfigDNS_REQUEST_ATTEMPTS               ( 3 ) // Changed from 2
  1. I have used Powershell nslookup for the ethernet connection and it returns:
PS C:\Users\User> nslookup a1c29udxup0qn9-ats.iot.eu-west-1.amazonaws.com
Server:  UnKnown
Address:  192.168.0.1

Non-authoritative answer:
Name:    a1c29udxup0qn9-ats.iot.eu-west-1.amazonaws.com
Addresses:  2a01:578:3::364b:e990
          2a01:578:3::364d:5172
          2a01:578:3::34d0:aa56
          2a01:578:3::3f8:197d
          2a01:578:3::22f1:60c6
          2a01:578:3::22f2:52cd
          2a01:578:3::341f:fa23
          2a01:578:3::3648:bd94
          52.213.144.6
          54.220.53.255
          54.154.138.253
          34.250.166.247
          52.31.106.148
          34.251.121.26
          52.31.195.63
          52.210.5.189
  1. Tried modifying the link, removing -ats etc. but no change to DNS server address or response
  2. Directly connected to 2 separate routers bypassing switch
  3. Ensured WiFi build and Ethernet build used the same link variable
  4. Checked MQTT broker port was set to 8883

Is there potentially a config setting I am not configuring correctly? I feel as though if there was a router issue the WiFi MQTT would also fail.

Any help is much appreciated,
Greg

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions