nRF Connect MQTT Sample Not Working as Expected

Hi, when I run the MQTT sample as is, I'm having problems with the TLS and port configuration. The terminal output is:

[00:01:33.046,783] <inf> transport: Connected to MQTT broker
[00:01:33.046,813] <inf> transport: Hostname: test.mosquitto.org
[00:01:33.046,875] <inf> transport: Client ID: 358299840022756
[00:01:33.046,875] <inf> transport: Port: 1883
[00:01:33.046,905] <inf> transport: TLS: No
[00:01:33.046,966] <inf> transport: Subscribing to: 358299840022756/my/subscribe/topic
[00:01:33.175,445] <inf> transport: Subscribed to topic 358299840022756/my/subscribe/topic

That looks correct, but on closer inspection the port is set to 1883 and TLS is turned off - neither of these are expected. I cannot see anywhere in the code where they're configured to those values; all I can find is CONFIG_MQTT_HELPER_PORT=8884 and CONFIG_MQTT_LIB_TLS=y (these appear in the logging function calls that output the above).

Any help or ideas would be much appreciated.

Parents Reply Children
  • Update: I added some #warning preprocessor directives to the mqtt/src/modules/transport/credentials_provision/credentials_provision.c to check that the certificates & keys were being included only to find they weren't.  I had assumed that mqtt/overlay-tls-nrf91.conf would automatically be used as I'm building for the nRF 9161 DK but it appears it wasn't.  So, I added the contents of that file to prj.conf.  Now I can find CONFIG_MQTT_HELPER_PORT and CONFIG_MQTT_LIB_TLS in build/zephyr/.config, but I'm now getting:

    [00:02:42.741,546] <err> mqtt_helper: mqtt_connect, error: -111
    [00:02:42.741,546] <err> transport: Failed connecting to MQTT, error code: -111

    So, the sample has now been modified, I suppose (I've also update the port and the broker domain)

  • Hi, 

    When building the unmodified MQTT sample with the command line, the following commands can be used for the nRF9161 DK:

    west build -b nrf9161dk_nrf9161_ns -- -DOVERLAY_CONFIG=overlay-tls-nrf91.conf

    Could you try the default setting?

    -Amanda H.

Related