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

Mqtt client Nrf9160 Module

My nrf9160 isn't responsive to the AT commands for MQTT mentioned here. I want to know why is that so?
I've put certificates in the module from AWS-Iot core and flashed at_client example inside the nrf9160 and trying to send AT#XMQTTCON command to connect it to the broker. 

Am I missing something or 
Is this a work in progress and these commands aren't available yet? 
I want to make use to this mqtt client to connect to AWS-IoT instead of doing in in the application, I suppose that'll be possible as well.

here in or at this place; where the speaker or writer is More (Definitions, Synonyms, Translation)

  • Have you tested the MQTT connection using e.g. Simple MQTT sample? Have a look at the answer my colleague Heidi gives here.

    Please make sure to use correct username, password and sec_tag for your certificates. Have you verified that you have added correct certificates?

  • I tried the simple one before and AWS-IoT example as well. I tried everything again.
    And it seems to be a problem with the MNO as  pointed out in the ticket you shared. 

    Now, I have tried two different MNOs KT and SK Telecom(by configuring with AT commands) and both of them have a problem with socket connection. 

    On AWS Cloudwatch I can see this 



    The AWS-IoT example in the NCS, I tried that as well, with two different ports: 8333 and 443.
    With 433 it gives the aws_iot_connect, error: -119 and with 8333 it gives E: mqtt_connect, error: -116.

    Can you highlight what else can I try?

  • Are you able to provide a full log output when connecting to AWS-IoT? Both with 433 and 8333. I  will discuss this with our R&D team. What modem fw are you running? And what is the network provider that you use?

    aws_iot_connect, error: -119 means "Connection already in progress", while mqtt_connect, error: -116 means "Connection timed out".

  • 8883-log.txt

    2021-01-22T02:21:26.337Z DEBUG modem >> AT+CFUN?
    2021-01-22T02:21:26.378Z DEBUG modem << +CFUN: 1
    2021-01-22T02:21:26.386Z DEBUG modem << OK
    2021-01-22T02:21:26.388Z DEBUG modem >> AT+CGSN=1
    2021-01-22T02:21:26.426Z DEBUG modem << +CGSN: "352656100371932"
    2021-01-22T02:21:26.428Z DEBUG modem << OK
    2021-01-22T02:21:26.433Z DEBUG modem >> AT+CGMI
    2021-01-22T02:21:26.483Z DEBUG modem << Nordic Semiconductor ASA
    2021-01-22T02:21:26.485Z DEBUG modem << OK
    2021-01-22T02:21:26.530Z DEBUG modem >> AT+CGMM
    2021-01-22T02:21:26.575Z DEBUG modem << nRF9160-SICA
    2021-01-22T02:21:26.578Z DEBUG modem << OK
    2021-01-22T02:21:26.583Z DEBUG modem >> AT+CGMR
    2021-01-22T02:21:26.626Z DEBUG modem << mfw_nrf9160_1.2.2
    2021-01-22T02:21:26.629Z DEBUG modem << OK
    2021-01-22T02:21:26.632Z INFO Nordic Semiconductor ASA nRF9160-SICA [mfw_nrf9160_1.2.2] SerNr: 352656100371932
    2021-01-22T02:21:26.633Z DEBUG modem >> AT+CEMODE?
    2021-01-22T02:21:26.688Z DEBUG modem << +CEMODE: 2
    2021-01-22T02:21:26.691Z DEBUG modem << OK
    2021-01-22T02:21:26.734Z DEBUG modem >> AT%XCBAND=?
    2021-01-22T02:21:26.773Z DEBUG modem << %XCBAND: (1,2,3,4,5,8,12,13,18,19,20,25,26,28,66)
    2021-01-22T02:21:26.775Z DEBUG modem << OK
    2021-01-22T02:21:26.842Z DEBUG modem >> AT+CMEE?
    2021-01-22T02:21:26.889Z DEBUG modem << +CMEE: 0
    2021-01-22T02:21:26.892Z DEBUG modem << OK
    2021-01-22T02:21:26.897Z DEBUG modem >> AT+CMEE=1
    2021-01-22T02:21:26.941Z DEBUG modem << OK
    2021-01-22T02:21:26.982Z DEBUG modem >> AT+CNEC?
    2021-01-22T02:21:27.016Z DEBUG modem << +CNEC: 0
    2021-01-22T02:21:27.019Z DEBUG modem << OK
    2021-01-22T02:21:27.021Z DEBUG modem >> AT+CNEC=24
    2021-01-22T02:21:27.056Z DEBUG modem << OK
    2021-01-22T02:21:27.085Z DEBUG modem >> AT+CGEREP?
    2021-01-22T02:21:27.119Z DEBUG modem << +CGEREP: 0,0
    2021-01-22T02:21:27.121Z DEBUG modem << OK
    2021-01-22T02:21:27.157Z DEBUG modem >> AT+CGDCONT?
    2021-01-22T02:21:27.194Z DEBUG modem << +CGDCONT: 0,"IP","iot.1nce.net","10.34.30.243",0,0
    2021-01-22T02:21:27.196Z DEBUG modem << OK
    2021-01-22T02:21:27.202Z DEBUG modem >> AT+CGACT?
    2021-01-22T02:21:27.235Z DEBUG modem << +CGACT: 0,1
    2021-01-22T02:21:27.238Z DEBUG modem << OK
    2021-01-22T02:21:27.277Z DEBUG modem >> AT+CGEREP=1
    2021-01-22T02:21:27.316Z DEBUG modem << OK
    2021-01-22T02:21:27.319Z DEBUG modem >> AT+CIND=1,1,1
    2021-01-22T02:21:27.355Z DEBUG modem << OK
    2021-01-22T02:21:27.393Z DEBUG modem >> AT+CEREG=5
    2021-01-22T02:21:27.437Z DEBUG modem << OK
    2021-01-22T02:21:27.487Z DEBUG modem >> AT+CEREG?
    2021-01-22T02:21:27.537Z DEBUG modem << +CEREG: 5,5,"1025","0074B707",7,,,"11100000","11100000"
    2021-01-22T02:21:27.540Z DEBUG modem << OK
    2021-01-22T02:21:27.584Z DEBUG modem >> AT+COPS=3,2
    2021-01-22T02:21:27.630Z DEBUG modem << OK
    2021-01-22T02:21:27.635Z DEBUG modem >> AT+COPS?
    2021-01-22T02:21:27.677Z DEBUG modem << +COPS: 0,2,"45005",7
    2021-01-22T02:21:27.680Z DEBUG modem << OK
    2021-01-22T02:21:27.732Z DEBUG modem >> AT%XCBAND
    2021-01-22T02:21:27.773Z DEBUG modem << %XCBAND: 5
    2021-01-22T02:21:27.776Z DEBUG modem << OK
    2021-01-22T02:21:27.825Z DEBUG modem >> AT+CGDCONT?
    2021-01-22T02:21:27.873Z DEBUG modem << +CGDCONT: 0,"IP","iot.1nce.net","10.34.30.243",0,0
    2021-01-22T02:21:27.875Z DEBUG modem << OK
    2021-01-22T02:21:27.915Z DEBUG modem >> AT+CGACT?
    2021-01-22T02:21:27.956Z DEBUG modem << +CGACT: 0,1
    2021-01-22T02:21:27.958Z DEBUG modem << OK
    2021-01-22T02:21:27.995Z DEBUG modem >> AT%CESQ=1
    2021-01-22T02:21:28.034Z DEBUG modem << OK
    2021-01-22T02:21:28.037Z DEBUG modem >> AT+CESQ
    2021-01-22T02:21:28.068Z DEBUG modem << +CESQ: 99,99,255,255,7,38
    2021-01-22T02:21:28.071Z DEBUG modem << OK
    2021-01-22T02:21:28.110Z DEBUG modem >> AT%XSIM=1
    2021-01-22T02:21:28.145Z DEBUG modem << OK
    2021-01-22T02:21:28.150Z DEBUG modem >> AT%XSIM?
    2021-01-22T02:21:28.196Z DEBUG modem << %XSIM: 1
    2021-01-22T02:21:28.198Z DEBUG modem << OK
    2021-01-22T02:21:28.202Z DEBUG modem >> AT+CPIN?
    2021-01-22T02:21:28.247Z DEBUG modem << +CPIN: READY
    2021-01-22T02:21:28.249Z DEBUG modem << OK
    2021-01-22T02:21:28.256Z DEBUG modem >> AT+CPINR="SIM PIN"
    2021-01-22T02:21:28.302Z DEBUG modem << +CPINR: "SIM PIN",3
    2021-01-22T02:21:28.305Z DEBUG modem << OK
    2021-01-22T02:21:28.346Z DEBUG modem >> AT+CIMI
    2021-01-22T02:21:28.389Z DEBUG modem << 901405101886716
    2021-01-22T02:21:28.392Z DEBUG modem << OK
    2021-01-22T02:21:28.395Z INFO IMSIdentity: 901405101886716
    2021-01-22T02:21:30.995Z INFO Modem port is closed
    2021-01-22T02:23:51.897Z INFO Modem port is opened
    2021-01-22T02:23:51.902Z DEBUG modem >> AT+CFUN?
    2021-01-22T02:23:51.940Z DEBUG modem << +CFUN: 1
    2021-01-22T02:23:51.942Z DEBUG modem << OK
    2021-01-22T02:23:51.995Z DEBUG modem >> AT+CGSN=1
    2021-01-22T02:23:52.003Z DEBUG modem << +CGSN: "352656100371932"
    2021-01-22T02:23:52.005Z DEBUG modem << OK
    2021-01-22T02:23:52.040Z DEBUG modem >> AT+CGMI
    2021-01-22T02:23:52.049Z DEBUG modem << Nordic Semiconductor ASA
    2021-01-22T02:23:52.053Z DEBUG modem << OK
    2021-01-22T02:23:52.057Z DEBUG modem >> AT+CGMM
    2021-01-22T02:23:52.091Z DEBUG modem << nRF9160-SICA
    2021-01-22T02:23:52.094Z DEBUG modem << OK
    2021-01-22T02:23:52.098Z DEBUG modem >> AT+CGMR
    2021-01-22T02:23:52.140Z DEBUG modem << mfw_nrf9160_1.2.2
    2021-01-22T02:23:52.143Z DEBUG modem << OK
    2021-01-22T02:23:52.145Z INFO Nordic Semiconductor ASA nRF9160-SICA [mfw_nrf9160_1.2.2] SerNr: 352656100371932
    2021-01-22T02:23:52.146Z DEBUG modem >> AT+CEMODE?
    2021-01-22T02:23:52.192Z DEBUG modem << +CEMODE: 2
    2021-01-22T02:23:52.194Z DEBUG modem << OK
    2021-01-22T02:23:52.232Z DEBUG modem >> AT%XCBAND=?
    2021-01-22T02:23:52.281Z DEBUG modem << %XCBAND: (1,2,3,4,5,8,12,13,18,19,20,25,26,28,66)
    2021-01-22T02:23:52.284Z DEBUG modem << OK
    2021-01-22T02:23:52.345Z DEBUG modem >> AT+CMEE?
    2021-01-22T02:23:52.398Z DEBUG modem << +CMEE: 1
    2021-01-22T02:23:52.401Z DEBUG modem << OK
    2021-01-22T02:23:52.405Z DEBUG modem >> AT+CNEC?
    2021-01-22T02:23:52.454Z DEBUG modem << +CNEC: 24
    2021-01-22T02:23:52.458Z DEBUG modem << OK
    2021-01-22T02:23:52.500Z DEBUG modem >> AT+CGEREP?
    2021-01-22T02:23:52.539Z DEBUG modem << +CGEREP: 1,0
    2021-01-22T02:23:52.542Z DEBUG modem << OK
    2021-01-22T02:23:52.546Z DEBUG modem >> AT+CIND=1,1,1
    2021-01-22T02:23:52.610Z DEBUG modem << OK
    2021-01-22T02:23:52.616Z DEBUG modem >> AT+CEREG=5
    2021-01-22T02:23:52.621Z DEBUG modem << OK
    2021-01-22T02:23:52.682Z DEBUG modem >> AT+CEREG?
    2021-01-22T02:23:52.735Z DEBUG modem << +CEREG: 5,5,"1025","0074B707",7,,,"11100000","11100000"
    2021-01-22T02:23:52.738Z DEBUG modem << OK
    2021-01-22T02:23:52.800Z DEBUG modem >> AT+COPS=3,2
    2021-01-22T02:23:52.843Z DEBUG modem << OK
    2021-01-22T02:23:52.850Z DEBUG modem >> AT+COPS?
    2021-01-22T02:23:52.910Z DEBUG modem << +COPS: 0,2,"45005",7
    2021-01-22T02:23:52.913Z DEBUG modem << OK
    2021-01-22T02:23:52.959Z DEBUG modem >> AT%XCBAND
    2021-01-22T02:23:52.997Z DEBUG modem << %XCBAND: 5
    2021-01-22T02:23:52.999Z DEBUG modem << OK
    2021-01-22T02:23:53.004Z DEBUG modem >> AT+CGDCONT?
    2021-01-22T02:23:53.056Z DEBUG modem << +CGDCONT: 0,"IP","iot.1nce.net","10.34.30.243",0,0
    2021-01-22T02:23:53.060Z DEBUG modem << OK
    2021-01-22T02:23:53.102Z DEBUG modem >> AT+CGACT?
    2021-01-22T02:23:53.155Z DEBUG modem << +CGACT: 0,1
    2021-01-22T02:23:53.159Z DEBUG modem << OK
    2021-01-22T02:23:53.207Z DEBUG modem >> AT%CESQ=1
    2021-01-22T02:23:53.244Z DEBUG modem << OK
    2021-01-22T02:23:53.248Z DEBUG modem >> AT+CESQ
    2021-01-22T02:23:53.255Z DEBUG modem << +CESQ: 99,99,255,255,14,44
    2021-01-22T02:23:53.301Z DEBUG modem << OK
    2021-01-22T02:23:53.354Z DEBUG modem >> AT%XSIM=1
    2021-01-22T02:23:53.395Z DEBUG modem << OK
    2021-01-22T02:23:53.400Z DEBUG modem >> AT%XSIM?
    2021-01-22T02:23:53.445Z DEBUG modem << %XSIM: 1
    2021-01-22T02:23:53.500Z DEBUG modem << OK
    2021-01-22T02:23:53.507Z DEBUG modem >> AT+CPIN?
    2021-01-22T02:23:53.565Z DEBUG modem << +CPIN: READY
    2021-01-22T02:23:53.567Z DEBUG modem << OK
    2021-01-22T02:23:53.618Z DEBUG modem >> AT+CPINR="SIM PIN"
    2021-01-22T02:23:53.663Z DEBUG modem << +CPINR: "SIM PIN",3
    2021-01-22T02:23:53.666Z DEBUG modem << OK
    2021-01-22T02:23:53.673Z DEBUG modem >> AT+CIMI
    2021-01-22T02:23:53.729Z DEBUG modem << 901405101886716
    2021-01-22T02:23:53.731Z DEBUG modem << OK
    2021-01-22T02:23:53.735Z INFO IMSIdentity: 901405101886716
    2021-01-22T02:23:59.579Z DEBUG modem << *** Booting Zephyr OS build v2.4.0-ncs1-1710-g5a7b4eb71047  ***
    2021-01-22T02:23:59.631Z DEBUG modem << [00:00:00.338,317] [0m<inf> mcuboot: Starting bootloader[0m
    2021-01-22T02:23:59.633Z DEBUG modem << [00:00:00.344,238] [0m<inf> mcuboot: Primary image: magic=unset, swap_type=0x1, copy_done=0x3, image_ok=0x1[0m
    2021-01-22T02:23:59.637Z DEBUG modem << [00:00:00.354,187] [0m<inf> mcuboot: Secondary image: magic=unset, swap_type=0x1, copy_done=0x3, image_ok=0x3[0m
    2021-01-22T02:23:59.639Z DEBUG modem << [00:00:00.364,318] [0m<inf> mcuboot: Boot source: none[0m
    2021-01-22T02:23:59.642Z DEBUG modem << [00:00:00.369,781] [0m<inf> mcuboot: Swap type: none[0m
    2021-01-22T02:23:59.703Z DEBUG modem << [00:00:00.420,806] [0m<inf> mcuboot: Bootloader chainload address offset: 0x10000[0m
    2021-01-22T02:23:59.706Z DEBUG modem << [00:00:00.428,436] [0m<inf> mcuboot: Jumping to the first image slot[0m
    2021-01-22T02:23:59.708Z DEBUG modem << ÿ*** Booting Zephyr OS build v2.4.0-ncs1-1710-g5a7b4eb71047  ***
    2021-01-22T02:23:59.711Z DEBUG modem << Flash regionsDomainPermissions
    2021-01-22T02:23:59.713Z DEBUG modem << 00 02 0x00000 0x18000 Securerwxl
    2021-01-22T02:23:59.715Z DEBUG modem << 03 31 0x18000 0x100000 Non-Securerwxl
    2021-01-22T02:23:59.716Z DEBUG modem << Non-secure callable region 0 placed in flash region 2 with size 32.
    2021-01-22T02:23:59.869Z DEBUG modem << SRAM regionDomainPermissions
    2021-01-22T02:23:59.873Z DEBUG modem << 00 07 0x00000 0x10000 Securerwxl
    2021-01-22T02:23:59.920Z DEBUG modem << 08 31 0x10000 0x40000 Non-Securerwxl
    2021-01-22T02:23:59.922Z DEBUG modem << PeripheralDomainStatus
    2021-01-22T02:23:59.924Z DEBUG modem << 00 NRF_P0               Non-SecureOK
    2021-01-22T02:23:59.927Z DEBUG modem << 01 NRF_CLOCK            Non-SecureOK
    2021-01-22T02:23:59.929Z DEBUG modem << 02 NRF_RTC0             Non-SecureOK
    2021-01-22T02:23:59.931Z DEBUG modem << 03 NRF_RTC1             Non-SecureOK
    2021-01-22T02:23:59.933Z DEBUG modem << 04 NRF_NVMC             Non-SecureOK
    2021-01-22T02:23:59.935Z DEBUG modem << 05 NRF_UARTE1           Non-SecureOK
    2021-01-22T02:23:59.936Z DEBUG modem << 06 NRF_UARTE2           SecureSKIP
    2021-01-22T02:23:59.937Z DEBUG modem << 07 NRF_TWIM2            Non-SecureOK
    2021-01-22T02:23:59.938Z DEBUG modem << 08 NRF_SPIM3            Non-SecureOK
    2021-01-22T02:23:59.940Z DEBUG modem << 09 NRF_TIMER0           Non-SecureOK
    2021-01-22T02:23:59.941Z DEBUG modem << 10 NRF_TIMER1           Non-SecureOK
    2021-01-22T02:23:59.996Z DEBUG modem << 11 NRF_TIMER2           Non-SecureOK
    2021-01-22T02:23:59.997Z DEBUG modem << 12 NRF_SAADC            Non-SecureOK
    2021-01-22T02:23:59.999Z DEBUG modem << 13 NRF_PWM0             Non-SecureOK
    2021-01-22T02:24:00.000Z DEBUG modem << 14 NRF_PWM1             Non-SecureOK
    2021-01-22T02:24:00.003Z DEBUG modem << 15 NRF_PWM2             Non-SecureOK
    2021-01-22T02:24:00.005Z DEBUG modem << 16 NRF_PWM3             Non-SecureOK
    2021-01-22T02:24:00.008Z DEBUG modem << 17 NRF_WDT              Non-SecureOK
    2021-01-22T02:24:00.010Z DEBUG modem << 18 NRF_IPC              Non-SecureOK
    2021-01-22T02:24:00.013Z DEBUG modem << 19 NRF_VMC              Non-SecureOK
    2021-01-22T02:24:00.016Z DEBUG modem << 20 NRF_FPU              Non-SecureOK
    2021-01-22T02:24:00.027Z DEBUG modem << 21 NRF_EGU1             Non-SecureOK
    2021-01-22T02:24:00.030Z DEBUG modem << 22 NRF_EGU2             Non-SecureOK
    2021-01-22T02:24:00.032Z DEBUG modem << 23 NRF_DPPIC            Non-SecureOK
    2021-01-22T02:24:00.034Z DEBUG modem << 24 NRF_GPIOTE1          Non-SecureOK
    2021-01-22T02:24:00.036Z DEBUG modem << 25 NRF_REGULATORS       Non-SecureOK
    2021-01-22T02:24:00.038Z DEBUG modem << SPM: NS image at 0x1c200
    2021-01-22T02:24:00.040Z DEBUG modem << SPM: NS MSP at 0x20029fe8
    2021-01-22T02:24:00.042Z DEBUG modem << SPM: NS reset vector at 0x223b5
    2021-01-22T02:24:00.045Z DEBUG modem << SPM: prepare to jump to Non-Secure image.
    2021-01-22T02:24:00.048Z DEBUG modem << *** Booting Zephyr OS build v2.4.0-ncs1-1710-g5a7b4eb71047  ***
    2021-01-22T02:24:00.050Z DEBUG modem << The AWS IoT sample started, version: v1.0.0
    2021-01-22T02:24:00.202Z DEBUG modem << D: Sending AT command to set system mode: AT%XSYSTEMMODE=1,0,0,0
    2021-01-22T02:24:00.241Z DEBUG modem << D: Sending AT command to set system mode: AT%XSYSTEMMODE=1,0,0,0
    2021-01-22T02:24:02.631Z DEBUG modem << D: +CEREG notification: +CEREG: 2,"1025","0074B707",7,0,0,"11100000","11100000"
    2021-01-22T02:24:02.678Z DEBUG modem << LTE cell changed: Cell ID: 7649031, Tracking area: 4133
    2021-01-22T02:24:02.680Z DEBUG modem << PSM parameter update: TAU: -1, Active time: -1
    2021-01-22T02:24:02.725Z DEBUG modem << D: +CSCON notification
    2021-01-22T02:24:02.727Z DEBUG modem << RRC mode: Connected
    2021-01-22T02:24:06.995Z DEBUG modem << D: +CEREG notification: +CEREG: 5,"1025","0074B707",7,,,"11100000","11100000"
    2021-01-22T02:24:07.033Z DEBUG modem << D: TAU: -1 sec, active time: -1 sec
    2021-01-22T02:24:07.095Z DEBUG modem << Network registration status: Connected - roaming
    2021-01-22T02:24:07.097Z DEBUG modem << DATE_TIME_OBTAINED_MODEM
    2021-01-22T02:24:07.099Z DEBUG modem << Next connection retry in 30 seconds
    2021-01-22T02:24:07.101Z DEBUG modem << AWS_IOT_EVT_CONNECTING
    2021-01-22T02:24:07.378Z DEBUG modem << D: IPv4 Address found 52.79.176.38
    2021-01-22T02:24:12.233Z DEBUG modem << D: AWS broker connection request sent.
    2021-01-22T02:24:24.588Z DEBUG modem << D: +CSCON notification
    2021-01-22T02:24:24.635Z DEBUG modem << RRC mode: Idle
    2021-01-22T02:24:37.011Z DEBUG modem << D: Connection poll in progress
    2021-01-22T02:24:37.056Z DEBUG modem << aws_iot_connect, error: -119
    2021-01-22T02:24:37.103Z DEBUG modem << Next connection retry in 30 seconds
    2021-01-22T02:25:07.019Z DEBUG modem << D: Connection poll in progress
    2021-01-22T02:25:07.060Z DEBUG modem << aws_iot_connect, error: -119
    2021-01-22T02:25:07.063Z DEBUG modem << Next connection retry in 30 seconds
    2021-01-22T02:25:10.803Z INFO Modem port is closed
    2021-01-22T02:25:19.083Z INFO Restoring from C:\Users\Usman Khan\AppData\Roaming\nrfconnect\pc-nrfconnect-linkmonitor\logs\2021-01-22T02_12_56.697Z-log.txt
    


    Are you able to provide a full log output when connecting to AWS-IoT?
    See attachments.

    What modem fw are you running?

    at+cgmr
    mfw_nrf9160_1.2.2


    And what is the network provider that you use?
    1nce SIM and tried with two MNOs : Korea Telecom and SKT

  • Hello, 

    I've been testing AWS_IoT on my side, and I'm not able to reproduce the error.

    Have you verified that CONFIG_AWS_IOT_CLIENT_ID_STATIC is configured to your Thing ID, and that your device is programmed with correct certificates which belong to your Thing ID? Have you used correct certificates? As described in step 9 of "Creating a thing in AWS IoT"?

    Also, have you configured correct Rest API Endpoint in CONFIG_AWS_IOT_BROKER_HOST_NAME ? And configured CONFIG_AWS_IOT_SEC_TAG to the correct sec tag used when provisioning certificates?

    I will test with the SLM MQTT API as well and get back to you.

    Kind regards,
    Øyvind

Related