nrf9160 mqtt simple example configured to talk to test.mosquitto.org using mutual TLS on port 8884?

Is there a configuration / sample available of mqtt simple to talk to the mosquitto server using an authenticated client on port 8884?  I saw a message on here that was about 2 years old that looked like it was trying to solve the same issue, but the modified sample code does not seem to build with the latest SDK?

Mosquitto has instructions for building the private key and signing the certificate using openssl and a webpage to paste the csr into.

Thank you in advance.

Parents
  • Another oddity.  We modified the MQTT sample to configure it for TLS as described 9 hours ago.

    We took the code that connected to port 8884 and the proj.cnf file and merged it into our working code (with GPS, I2C, SPI Flash, etc.) and we can not connect to test.mosquitto.org on port 8884.  We seem to get random errors.   Errors -12, -111, -116, and -104 after some period of trying to connect to the server.

    Any suggestions on how to debug this?  How to get more information from the system as to what's going on?

    Back to frustrated...

Reply
  • Another oddity.  We modified the MQTT sample to configure it for TLS as described 9 hours ago.

    We took the code that connected to port 8884 and the proj.cnf file and merged it into our working code (with GPS, I2C, SPI Flash, etc.) and we can not connect to test.mosquitto.org on port 8884.  We seem to get random errors.   Errors -12, -111, -116, and -104 after some period of trying to connect to the server.

    Any suggestions on how to debug this?  How to get more information from the system as to what's going on?

    Back to frustrated...

Children
  • Sorry to hear about this frustration. 

    Richard W Mincher said:
    Any suggestions on how to debug this?  How to get more information from the system as to what's going on?

    Yes, we will need to see a modem trace captured with the Trace Collector v2. Make sure to follow instructions and reset device after starting the trace collector. What modem FW and nRF Connect SDK version are you working on?

    Richard W Mincher said:
    rrors -12, -111, -116, and -104 after some period of trying to connect to the server.

    When do you get the errors? From nrfxlib\nrf_modem\include\nrf_errno.h

    #define NRF_ENOMEM 12           /**< Not enough space */
    #define NRF_ECONNRESET 104      /**< Connection reset */
    #define NRF_ECONNREFUSED 111    /**< Connection refused */
    #define NRF_ETIMEDOUT 116       /**< Connection timed out */
    Are you able to share more information on you configuration? I found this support ticket regarding ENOMEM and ECONNRESET when connecting to MQTT.
  • I'll take a look at the ticket you reference above and see if I can figure out how to get tracing to work with the feather board.

    In the meantime, we seem to have enabled some modem debugging messages.  Are these messages useful?  You can see the -12 failures from the client in there.

    LTE Link Connecting...+CEREG: 2,"8B3B","0A141511",7
    +CSCON: 1
    +CEREG: 5,"8B3B","0A141511",7,,,"00100011","00101000"
    +CEDRXP: 4,"1001","1001","0001"
    LTE Link Connected![00:01:27.160,888] <inf> mqtt_simple: The MQTT simple sample started
    [00:01:28.102,325] <inf> mqtt_simple: IPv4 Address found 5.196.95.208
    [00:01:28.109,222] <dbg> mqtt_simple: client_id_get: client_id = xyzzy.hello.world
    [00:01:28.117,187] <inf> mqtt_simple: TLS enabled
    +CSCON: 0
    +CEREG: 5,"8B3B","0A150111",7,,,"00100011","00101000"
    +CSCON: 1
    +CSCON: 0
    +CEREG: 2
    +CEREG: 5,"8B3B","0A141511",7,,,"00100011","00101000"
    +CEREG: 5,"8B3B","0A150111",7,,,"00100011","00101000"
    +CSCON: 1
    +CSCON: 0
    +CEREG: 2
    +CEREG: 2,"3A66","02DD5905",7
    +CSCON: 1
    [00:01:46.104,125] <err> mqtt_simple: mqtt_+CEREG: 2,"3A66","02DD5905",7,0,9
    connect -115
    [00:01:46.113,342] <inf> mqtt_simple: Reconnecting in 60 seconds...
    +CSCON: 0
    +CEREG: 2,"3A66","02DD5904",7
    +CSCON: 1
    +CEREG: 5,"3A66","02DD5904",7,,,"11100000","11100000"
    +CEDRXP: 4,"1001","",""
    +CSCON: 0
    +CSCON: 1
    +CSCON: 0
    +CEREG: 5,"3A66","02DD5905",7,,,"11100000","11100000"
    +CEREG: 5,"3A66","02DD5904",7,,,"11100000","11100000"
    +CSCON: 1
    +CSCON: 0
    +CEREG: 5,"3A66","02DD5905",7,,,"11100000","11100000"
    +CSCON: 1
    +CSCON: 0
    +CSCON: 1
    [00:02:57.253,051] <err> mqtt_simple: mqtt_connect -12
    [00:02:57.258,880] <inf> mqtt_simple: Reconnecting in 60 seconds...
    +CSCON: 0
    +CEREG: 5,"3A66","02DD5904",7,,,"11100000","11100000"
    +CSCON: 1
    +CSCON: 0
    +CEREG: 5,"3A66","02DD5905",7,,,"11100000","11100000"
    +CSCON: 1
    +CSCON: 0
    +CEREG: 5,"3A66","02DD5904",7,,,"11100000","11100000"
    +CSCON: 1
    [00:04:08.701,690] <err> mqtt_simple: mqtt_connect -12
    [00:04:08.707,519] <inf> mqtt_simple: Reconnecting in 60 seconds...
    +CSCON: 0

  • After doing a lot more trial and error  (comparing source code and configs) it appears that we can get the failing code to work if we build for a non-debug configuration.  If I build for a debug configuration I get random failures.  This is unfortunate.

    Is this an indication of some issue?  Stack?  Heap?  Optimization timing?  I'm hoping we can resolve debugging -- I'm use to debugging with print and gpio lines, but having a debugger (either in VC or Ozone) is a big plus.

    FYI, we are using SDK 2.0.0, and modem firmware 1.3.2 (the latest).

    Thanks.

  • Richard W Mincher said:
     [00:01:46.104,125] <err> mqtt_simple: mqtt_+CEREG: 2,"3A66","02DD5905",7,0,9 connect -115

    From the CEREG response we can see that your device is rejected by the network (https://telecompedia.net/lte-release-causes/)

    Cause #9 – UE identity cannot be derived by the network.

          This EMM cause is sent to the UE when the network cannot derive the UE’s identity from the GUTI/S-TMSI/P-TMSI and RAI e.g. no matching identity/context in the network or failure to validate the UE’s identity due to integrity check failure of the received message.

    We will need to see more via the modem trace. 

    Regarding the errno -12. Have you increased the memory in mqtt_simple? From nrf\samples\nrf9160\mqtt_simple\prj.conf

    # Memory
    CONFIG_MAIN_STACK_SIZE=4096
    CONFIG_HEAP_MEM_POOL_SIZE=2048

    Kind regards,
    Øyvind

Related