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

MQTT Publisher Example - mqtt_connect error 51460

Hello,

I am currently trying to use the MQTT publisher example to send a message to a locally hosted MQTT broker (I assume I can use a local IPv6 address?).  The MQTT broker I'm using is mosquitto, and I have confirmed that it is able to receive messages by using mosquitto_pub and mosquitto_sub.

I have been able to setup the IPv6 interface using 6LoWPAN on a Raspberry Pi, however when I attempt to connect to my MQTT broker I get the error 51460 (NRF_ERROR_NO_MEM | IOT_MQTT_ERR_BASE) in the function mqtt_connect. I assume this indicates that there is insufficient memory to complete the connection.

I'm using the example in SDK v16 and have made very few changes. I have changed things such as the broker address and security settings.

I'm unsure of how to fix this issue, so if someone could point out what I may be doing wrong that would be great.

Thanks for any help,

Matthew

  • Hi,

    mqtt_connect seems to return NO_MEM if the maximum number of clients have been reached, or if the p_client->p_packet parameter is NULL:

    if ((client_index == MQTT_MAX_CLIENTS) || (p_client->p_packet == NULL))
    {
        err_code = (NRF_ERROR_NO_MEM | IOT_MQTT_ERR_BASE);
    }

    Do this happen om the first call to mqtt_connect? MQTT_MAX_CLIENTS is set in the sdk_config.h file, and defaults to 1 in the examples.

    p_client->p_packet will be set to NULL if nrf_malloc cannot provide a large enough buffer for the requested packet length:

    p_client->p_packet = nrf_malloc(MQTT_MAX_PACKET_LENGTH);

    You can try to reduce the MQTT_MAX_PACKET_LENGTH to see if this helps solve the issue. It can be set down to 5.

    Best regards,
    Jørgen

  • Hi Jørgen,

    Thanks for your reply. I release now that the error was due to calling the function more than once, and I am now no longer seeing this issue.

    Thanks for the help.

Related