AWS IoT FOTA Error nRF7002DK: Failed to create socket, err 12

After a lot of trial and error, I finally have an AWS IoT build running on my 7002dk. I am running the sample from the main branch of nRF Connect building with the command line.

west build -b nrf7002dk_nrf5340_cpuapp
west flash

My dev kit is successfully connecting to the broker and sending shadow updates. However, I need to make a proof of concept FOTA. Following the guide, I am able to get an update job started over https.

However, I am getting an error saying: download_client: Failed to create socket, err 12.

I am not sure where to look to start debugging. What am I missing?

[00:01:36.774,902] <inf> aws_iot_sample: AWS_IOT_EVT_PUBACK, message ID: 21781
[00:01:36.775,207] <inf> download_client: Downloading: app_update.bin [0]
[00:01:36.775,268] <inf> aws_iot_sample: AWS_IOT_EVT_FOTA_START
[00:01:36.814,697] <err> download_client: Failed to create socket, err 12
[00:01:36.814,727] <err> fota_download: Download client error
[00:01:36.814,758] <err> aws_fota: FOTA_DOWNLOAD_EVT_ERROR
[00:01:36.814,788] <err> aws_iot: AWS_FOTA_EVT_ERROR
[00:01:36.814,788] <inf> aws_iot_sample: AWS_IOT_EVT_FOTA_ERROR
[00:01:36.966,064] <inf> aws_iot_sample: AWS_IOT_EVT_PUBACK, message ID: 26704
[00:01:37.106,048] <inf> aws_iot_sample: AWS_IOT_EVT_PUBACK, message ID: 31885


Maybe some relevant config settings:

CONFIG_AWS_IOT=y
CONFIG_AWS_IOT_CLIENT_ID_STATIC="thing_name"
CONFIG_AWS_IOT_BROKER_HOST_NAME="aws_endpoint"
CONFIG_AWS_IOT_SEC_TAG=201
CONFIG_AWS_FOTA_DOWNLOAD_SECURITY_TAG=401

CONFIG_WIFI_CREDENTIALS_STATIC=y
CONFIG_WIFI_CREDENTIALS_STATIC_SSID="ssid"
CONFIG_WIFI_CREDENTIALS_STATIC_PASSWORD="pass"

  • Hi

    Errno 2 refers to there being no such file directory or entry, so I guess it's referring to either of the parameters for the connect() function aren't found in your project: 

    err = connect(dl->fd, &dl->remote_addr, addrlen);

    Double check what these values actually return or what directories/entries they are pulled from to see if that helps you at all.

    Best regards,

    Simon

  • Hi Simon,
    I include the CONFIG_DOWNLOAD_CLIENT_LOG_LEVEL_DBG=y configuration option in my prj.conf file. Here is what the download_client is logging now:

    [00:01:29.936,431] <inf> aws_iot_sample: AWS_IOT_EVT_PUBACK, message ID: 60158
    [00:01:29.937,347] <dbg> download_client: set_state: state = 1
    [00:01:29.937,377] <inf> download_client: Downloading: app_update.bin [0]
    [00:01:29.937,438] <inf> aws_iot_sample: AWS_IOT_EVT_FOTA_START
    [00:01:30.241,943] <dbg> download_client: client_connect: Protocol not specified, defaulting to HTTP(S)
    [00:01:30.242,004] <dbg> download_client: client_connect: Port not specified, using default: 443
    [00:01:30.242,004] <dbg> download_client: client_connect: family: 1, type: 1, proto: 258
    [00:01:30.242,614] <inf> download_client: Setting up TLS credentials, sec tag count 1
    [00:01:30.242,736] <inf> download_client: Connecting to silver-firmware-ota.s3.us-east-1.amazonaws.com
    [00:01:30.242,767] <inf> download_client: fd 9, addrlen 8, fam IPv4, port 443
    [00:01:30.336,761] <err> download_client: Unable to connect, errno 2
    [00:01:30.338,012] <dbg> download_client: set_state: state = 0
    [00:01:30.338,012] <inf> aws_iot_sample: AWS_IOT_EVT_FOTA_DL_PROGRESS, (100%)
    [00:01:30.343,750] <err> fota_download: Download client error
    [00:01:30.495,941] <inf> aws_iot_sample: AWS_IOT_EVT_PUBACK, message ID: 11081
    [00:01:30.497,497] <inf> aws_iot_sample: AWS_IOT_EVT_FOTA_DONE
    [00:01:30.505,096] <inf> aws_iot_sample: AWS_IOT_EVT_DISCONNECTED
    [00:01:30.505,126] <wrn> aws_iot_sample: Unexpected FOTA image type


    Does this add any clarity? Am I missing a configuration somewhere? Is FOTA working currently with the latest aws_iot sample?

  • Hi

    After this fix was added to increase the number of TLS contexts and file descriptors the AWS_IoT should be able to do FOTA. I see that the port you're using is the default one, can you confirm is this is intended or not, and that silver-firmware-ota.s3.us-east-1.amazonaws.com is the server you want to connect to? The error is still the same, as one of the params in your connect() function aren't found in your project.

    Best regards,

    Simon

  • Hi Simon, 

    You are correct, I have not changed the port from the default one. I don't see any mention of ports in the AWS FOTA configuration guide. Is this something I need to configure? Is that on the AWS side or the project side, or both?

    I can confirm that silver-firmware-ota.s3.us-east-1.amazonaws.com is the server I am attempting to connect to. 

    Are you implying that I am missing one of the params in my configuration? Can you point me to which configuration variables are missing? Is there a step in the FOTA guide that I missed?

  • I can't see that you're missing anything specifically, I'm just saying what the error code you get implies, which is that either of the parameters in the connect() function of the download_client isn't found when running your project, meaning that either of the parameters in this function aren't fulfilled in your project. I don't have a clear idea of why at the moment I'm afraid, but please check your project what these are set as on your end. 

    	err = connect(dl->fd, &dl->remote_addr, addrlen);
    	if (err) {
    		err = -errno;
    		LOG_ERR("Unable to connect, errno %d", -err);
    	}

    Best regards,

    Simon

Related