MQTT over Wi-Fi (nRF7002DK) - can not connect

Hello

I am trying to connect to an MQTT broker over wi-fi using the nRF7002-DK.
The code that I wrote is based on the mqtt_over_wifi_nrf7002DK example (https://github.com/AliNordic/mqtt_over_wifi_nrf7002DK), so the functions and the basic operation is similar.
I can successfully connect to the wi-fi network, the DHCP gives me an IP address.
Also, the client_init function and the mqtt_connect function returns no error.
But the mqtt_publish function returns -128, which means "Socket is not connected"
Maybe this makes sense since the 
MQTT_EVT_CONNACK callback never gets called (which I think it means that it is not connected to the MQTT) although from the LOG information the net_mqtt returns: Connect completed.

Bellow is the logging information.
 LOG information

prj.conf

main.c

I think I have followed the right operations in order to connect to an MQTT broker, but is there something that I am missing?

Thank you

Parents
  • Hi,

    Based on the state in your log, you have established TCP connection, but not MQTT connection (

    /** TCP Connection successfully established. */
    MQTT_STATE_TCP_CONNECTED = 0x00000002

    /** MQTT Connection successful. */
    MQTT_STATE_CONNECTED = 0x00000004

    Have you tried connecting to a public MQTT broker (e.g. test.mosquitto.org or broker.hivemq.com) without MQTT username and password?

    Best regards,
    Marte

Reply
  • Hi,

    Based on the state in your log, you have established TCP connection, but not MQTT connection (

    /** TCP Connection successfully established. */
    MQTT_STATE_TCP_CONNECTED = 0x00000002

    /** MQTT Connection successful. */
    MQTT_STATE_CONNECTED = 0x00000004

    Have you tried connecting to a public MQTT broker (e.g. test.mosquitto.org or broker.hivemq.com) without MQTT username and password?

    Best regards,
    Marte

Children