This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

AWS_FOTA: ERROR: mqtt_connect -22

Hello, I've been having problems getting the AWS_FOTA sample working on a nrf9160 DK.
At first, the device got stuck as it was downloading the firmware update, at 2%. I was able to fix this by setting CONFIG_DFU_TARGET_MCUBOOT_SAVE_PROGRESS=n. After that, the download got stuck at around 11%, though that number changed a bit each time I ran it. While I was trying to fix that, the device stopped being able to connect to AWS at all, even though I didn't change anything. The device waits for a long time after the "client_id:" line, and then seems to time out and print "ERROR: mqtt_connect -22". The timeout/error seems to come from mqtt_connect -> mqtt_client_tls_connect -> connect (line 87 in mqtt_transport_socket_tls.c). I am able to connect to AWS IoT from a python client on my computer using the same credentials and MQTT broker, so I don't think it's a problem with the AWS server.
Here are the changes I made to prj.conf:
CONFIG_DFU_TARGET_MCUBOOT_SAVE_PROGRESS=n
CONFIG_CLOUD_CERT_SEC_TAG=5
CONFIG_APP_VERSION="v1"
CONFIG_MQTT_BROKER_HOSTNAME="ahykgwaormc93-ats.iot.us-west-2.amazonaws.com"
CONFIG_USE_CLOUD_CLIENT_ID=y
CONFIG_CLOUD_CLIENT_ID="nrf9160dk"
CONFIG_USE_NRF_CLOUD=n
Besides that and the credentials (ran once with CONFIG_PROVISION_CERTIFICATES), I didn't make any changes to the AWS_FOTA sample.
I tried both the master branch and the v1.2.0 branch. I also stuff like turning CONFIG_DFU_TARGET_MCUBOOT_SAVE_PROGRESS on again, and re-flashing the credentials with CONFIG_PROVISION_CERTIFICATES again.
Parents
  • Hello, 

    From nrfxlib\bsdlib\include\nrf_errno.h

    Fullscreen
    1
    #define NRF_EINVAL 22 /**< Invalid argument */
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    I've had no issues with the AWS FOTA sample (tested yesterday). Can you please provide the output from i.e. LTE Link Monitor? 

    Kind regards,
    Øyvind

  • OK, here's the output

  • I am using iBasis, and I seem to have enough data. I also tried a test application that sends and receives on a UDP socket, which also works.

    I tried the more restrictive policy, but that didn't fix the problem, still an error with mqtt_connect -22.

    About the default configuration - I wasn't aware that this example even worked with nrf cloud until just now.  Reverting the repository doesn't work (the broker is set to your_aws_mqtt_broker_hostname.amazonaws.com by default, which causes "getaddrinfo failed -11"), and when I set CONFIG_USE_NRF_CLOUD=y, I get the same problem as before (mqtt_connect -22)

    Here is the output of the AT Client.

  • icampbell said:
    I am using iBasis, and I seem to have enough data

     Yes, should be enough. 

     

    icampbell said:
    About the default configuration - I wasn't aware that this example even worked with nrf cloud until just now

     No, this should not work with nRF Cloud from what I am told. It is designed to work nRF Cloud in the beginning, but some changes were introduced to nRF Cloud which made it not work with nRF Cloud. nRF Cloud is based on AWS, and will, therefore, have a similar address. 

     

    icampbell said:
    Here is the output of the AT Client.

     Can you please click on Open Log File, then save and send a full log file?

    From the information you give, there seems to be a mismatch between your prj.conf and the AWS MQTT settings. Are you using SES when building and programming? What I am fearing, is that the settings you add in prj.conf are overwritten by kconfig. E.g. your client-id does not match in the latest output:

  • Here's the log from AT client:

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    2020-03-26T14:07:31.789Z INFO Application data folder: /home/icampbell/.config/nrfconnect/pc-nrfconnect-linkmonitor
    2020-03-26T14:07:31.861Z DEBUG App pc-nrfconnect-linkmonitor v1.1.1 official
    2020-03-26T14:07:31.861Z DEBUG App path: /home/icampbell/.nrfconnect-apps/node_modules/pc-nrfconnect-linkmonitor
    2020-03-26T14:07:31.862Z DEBUG nRFConnect 3.3.0 is supported by the app (^3.2.0)
    2020-03-26T14:07:31.862Z DEBUG nRFConnect path: /tmp/.mount_nrfconDssE2Z/resources/app.asar
    2020-03-26T14:07:31.862Z DEBUG HomeDir: /home/icampbell
    2020-03-26T14:07:31.862Z DEBUG TmpDir: /tmp
    2020-03-26T14:07:31.924Z VERBOSE Could not fetch serial number for serial port at /dev/ttyS0
    2020-03-26T14:07:31.924Z VERBOSE Could not fetch serial number for serial port at /dev/ttyS1
    2020-03-26T14:07:31.924Z VERBOSE Could not fetch serial number for serial port at /dev/ttyS10
    2020-03-26T14:07:31.924Z VERBOSE Could not fetch serial number for serial port at /dev/ttyS11
    2020-03-26T14:07:31.925Z VERBOSE Could not fetch serial number for serial port at /dev/ttyS12
    2020-03-26T14:07:31.925Z VERBOSE Could not fetch serial number for serial port at /dev/ttyS13
    2020-03-26T14:07:31.925Z VERBOSE Could not fetch serial number for serial port at /dev/ttyS14
    2020-03-26T14:07:31.925Z VERBOSE Could not fetch serial number for serial port at /dev/ttyS15
    2020-03-26T14:07:31.925Z VERBOSE Could not fetch serial number for serial port at /dev/ttyS16
    2020-03-26T14:07:31.925Z VERBOSE Could not fetch serial number for serial port at /dev/ttyS17
    2020-03-26T14:07:31.925Z VERBOSE Could not fetch serial number for serial port at /dev/ttyS18
    2020-03-26T14:07:31.925Z VERBOSE Could not fetch serial number for serial port at /dev/ttyS19
    2020-03-26T14:07:31.925Z VERBOSE Could not fetch serial number for serial port at /dev/ttyS2
    2020-03-26T14:07:31.925Z VERBOSE Could not fetch serial number for serial port at /dev/ttyS20
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    there seems to be a mismatch between your prj.conf and the AWS MQTT settings

    No, the output there is from when I ran it with CONFIG_USE_NRF_CLOUD=y, which changes the client id, so it's expected behavior. Running with the config I posted earlier to connect to my AWS account, it still produces the same output as in my original post, where the client-id outputs as "nrf9160dk" as expected. I am using west build / west flash, but changes made to prj.conf are definitely taking effect.

  • I think we need to have a look at the modem connection. Can you please provide a modem trace?

    Thanks!
    -Øyvind

  • trace-2020-03-26T14-58-36.611Z.bin

    Here you go. I rebooted the device just after I started the trace, and ended the trace just after it printed "mqtt_connect -22".

Reply Children
  • Thank you! I will look into the modem trace and the log output to see if there is anything causing this issue. 

    Will get back to you asap.

    Kind regards,

    Øyvind

  • Hello again, 

    I'm sorry, so far I've got nothing from the modem trace or log. Can you please try updating the modem FW to mfw 1.1.1? If this does not fix the issue, can you please provide your project?

    Thanks!

    Kind regards,
    Øyvind

  • Hello,

    I updated the modem firmware to 1.1.1, but I still have the same problem.

    I sent you a PM with a link to my project. To use it you would have to uncomment CONFIG_PROVISION_CERTIFICATES=y.

  • Hello, 

    I was not able to build your project, but am working on a solution. However, I found that your CLOUD_CLIENT_PRIVATE_KEY in certificates.h had an extra space after \n". This can cause issues with certificates. 
    Please remove and let me know how it goes!


    Kind regards,
    Øyvind

  • I removed the extra spaces, but unfortunately it still says "ERROR: mqtt_connect -22".

    The project should build. I'm on the "master" branch of the sdk, if that helps (I have also tried v1.2.0, rebased off of the v1.2.0 aws_fota sample, but it had the same problem).