Issue with Missing #MQTTEVT After MQTT Connection on nRF9160

    1. Description:

      I am working on an application using the nRF9160 and encountered an issue where the #MQTTEVT event is not triggered after connecting to an MQTT broker using the AT#XMQTTCON command. Based on my understanding, the expected behavior is for #MQTTEVT to respond with (0,0) upon successfully establishing the connection, but this event is missing in my case.

      Below is the sequence of commands and full logs:

    [19:24:15] ➞ AT#XRESET  
    [19:24:15] ➞  
    OK  
    [19:24:18] ➞ Ready  
    [19:24:18] ➞ AT#XMODEMRESET  
    [19:24:18] ➞  
    #XMODEMRESET: 0  
    
    OK  
    [19:24:18] ➞ AT+CFUN=0  
    [19:24:19] ➞  
    OK  
    AT%XSYSTEMMODE=1,1,0,1  
    [19:24:19] ➞  
    OK  
    AT+CFUN=1  
    [19:24:19] ➞  
    OK  
    AT+CFUN?  
    [19:24:19] ➞  
    +CFUN: 1  
    
    OK  
    [19:24:19] ➞ AT+CGDCONT=1,"IP","NB-IOT.CLARO.COM.BR"  
    [19:24:20] ➞  
    OK  
    AT+CEREG=1  
    [19:24:20] ➞  
    OK  
    [19:24:20] ➞ AT+CEREG?  
    [19:24:21] ➞  
    +CEREG: 1,4  
    
    OK  
    [19:24:21] ➞ AT+CEREG?  
    [19:24:22] ➞  
    +CEREG: 1,4  
    
    OK  
    [19:24:22] ➞ AT+CEREG?  
    [19:24:23] ➞  
    +CEREG: 1,2  
    
    OK  
    [19:24:23] ➞ AT+CEREG?  
    [19:24:24] ➞  
    +CEREG: 1,1  
    
    OK  
    [19:24:24] ➞ AT+CESQ=0  
    [19:24:24] ➞  
    +CESQ: 99,99,255,255,11,54  
    
    OK  
    [19:24:24] ➞ AT#XMQTTCFG="370026001950424B30373620",60,1  
    [19:24:24] ➞  
    OK  
    [19:24:24] ➞ AT#XMQTTCON=1,"","","broker.hivemq.com",1883  
    [19:24:24] ➞  
    OK  
    [19:24:34] ➞ AT#XMQTTCON?  
    [19:24:34] ➞  
    #XMQTTCON: 1,"370026001950424B30373620","broker.hivemq.com",1883  
    
    OK  
    [19:24:36] ➞ AT#XMQTTPUB="globals/370026001950424B30373620/","",2,0  
    [19:24:36] ➞  
    OK  
    {"SN":"370026001950424B30373620","VRX":14514,"VMX":63518,"VRZ":14097,"VMZ":63494,"TEMP":7153,"BAT":36073,"RSSI":-87}+++  
    [19:24:36] ➞  
    #XDATAMODE: 116  
    [19:24:36] ➞  
    #XDATAMODE: 0  
    [19:24:38] ➞  
    #XMQTTEVT: 4,0  
    [19:24:38] ➞  
    #XMQTTEVT: 6,0  
    [19:24:39] ➞ AT#XMQTTCON=0  
    [19:24:39] ➞  
    #XMQTTEVT: 1,0  

    Observed Behavior:

    1. After sending AT#XMQTTCON=1,"","","broker.hivemq.com",1883, I receive an OK, but there’s no immediate #MQTTEVT (0,0) event to confirm the connection.
    2. The connection appears to be established successfully after roughly 10 seconds, as verified by AT#XMQTTCON?, but I didnt want to use magical delays.
    3. Subsequent operations, like publishing messages (AT#XMQTTPUB), work as expected, and other events like #XMQTTEVT (4,0) and #XMQTTEVT (6,0) are triggered correctly.

    Expected Behavior:

    From what I’ve read, the normal behavior is for #MQTTEVT to send (0,0) shortly after executing AT#XMQTTCON=1,.... This event is critical for precisely handling the connection status in real-time applications. Arbitrary delays are not reliable for production use.


    Questions:

    1. Is the absence of the #MQTTEVT (0,0) event expected in this scenario, or is it a potential bug?
    2. Are there specific configurations or firmware versions required to ensure this event is triggered?
    3. Could this behavior be related to the broker’s response time, or is it more likely a modem issue?

Additional Details:

  • MQTT Broker: HiveMQ (broker.hivemq.com) on port 1883
  • Modem Firmware Version: [fw 1.3.7]
  • Development Environment: [2.8.0 sdk version]
  • Sometimes I see the #MQTTEVT (0,0) after the mqtt publication, but I dont know why this happen and isnt a consistent behaviour.

Any guidance or suggestions would be greatly appreciated. Thank you!

  • Hello, 

    I'm not able to reproduce, testing with two boards. One nRF9151 and one nrf9160.

    OK
    > at+CFUN=1
    
    OK
    > at+cereg=5
    
    OK
    
    +CEREG: 5,"08FF","01E2D215",7,,,"11100000","11100000"
    > AT#XMQTTCFG="Thingy91_sykkylven",60,1
    
    OK
    > AT#XMQTTCON=1,"","","broker.hivemq.com",1883
    
    OK
    
    #XMQTTEVT: 0,0
    
    #XMQTTEVT: 9,0
    > T#XMQTTPUB="globals/Thingy91_sykkylven/","",2,0
    
    ERROR
    > AT#XMQTTCON?
    
    #XMQTTCON: 1,"Thingy91_sykkylven","broker.hivemq.com",1883
    
    OK
    > AT#XMQTTPUB="globals/Thingy91_sykkylven/","",2,0
    
    OK
    
    #XMQTTEVT: 9,0


    Ready
    > at
    
    OK
    > AT%XSYSTEMMODE=1,1,0,1
    
    OK
    > at+CFUN=1
    
    OK
    > at+cereg=5
    
    OK
    
    +CEREG: 2,"8173","01172803",7
    
    +CEREG: 5,"8173","01172803",7,,,"11100000","11100000"
    > AT#XMQTTCFG="91dk_sykkylven",60,1
    
    OK
    > AT#XMQTTCON=1,"","","broker.hivemq.com",1883
    
    OK
    
    #XMQTTEVT: 0,0
    > AT#XMQTTPUB="globals/91dk_sykkylven/","",2,0
    
    OK
    
    #XMQTTEVT: 9,0


    Could there be an issue with your network/signal strength? Could you please provide a modem trace from your device? 

    Kind regards,
    Øyvind

Related