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

    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 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).

  • I was able to build on master, not on tag v1.2.0. And the project worked as intended. Below is the output from LTE Link Monitor. (Missed the first part of startup)

    I see I'm getting the same issue as you did at first, stopping at 2%. 

    " Server did not send "Content-Range" in response

  • Yes, building it on master is expected (I changed the code when I built it on v1.2.0).

    The project working is strange, considering my device still doesn't work. Any idea what might be causing this?

    Also, I remember when my device got to 2%, it just hung on that line ("Downloaded 4096/183300 bytes (2%)"), not printed out an error after. Did it hang a really long time on that line for you?

  • icampbell said:
    Did it hang a really long time on that line for you?

     No, the log shows that it failed immediately. 

    What does your job file look like?

  • So, I tested it today and it spontaneously started working again. I didn't even have to re-flash the device, the code that wasn't working earlier started working again today. I don't think I made any changes on AWS, either. I even tested a FOTA update and it worked.

    Here's the logs from when it worked

    Here's the job file you asked about

    So I guess the problem is fixed now?

Reply
  • So, I tested it today and it spontaneously started working again. I didn't even have to re-flash the device, the code that wasn't working earlier started working again today. I don't think I made any changes on AWS, either. I even tested a FOTA update and it worked.

    Here's the logs from when it worked

    Here's the job file you asked about

    So I guess the problem is fixed now?

Children
  • This looks very promising. I'm a little baffled why it suddenly started to work, but nothing is better than this result. 

    Let's close for now, and if it does occur again please let us know. 

    Kind regards,
    Øyvind