nRF7002 DK not able to connect to Beebotte MQTT broker after setting correct username

Hi,

I have nRF7002 DK and have previously connected to broker.hivemq.com following the guide below.

https://devzone.nordicsemi.com/nordic/nordic-blog/b/blog/posts/implementing-mqtt-over-wi-fi-on-the-nrf7002-development-kit

Now, I am trying to connect Beebotte MQTT, because I need to connect MQTT to IFTTT. Beebotte MQTT enable me to do that. To connect to Beebotte MQTT, a username is required "token_xxxxxxxxxx". I used MQTTBox at windows to connect to Beebotte using these client settings below. I confirmed the payload was received at Beebotte.

However, using nRF7002 DK setting the correct username and subscription topic does not work and it disconnects.

/**@brief Initialize the MQTT client structure
 */
int client_init(struct mqtt_client *client)
{
	int err;	

	char pass[35] = "";
	char user[35] = "token_xxxxxxxxxxxxxxx";
    
	static struct mqtt_utf8 password;
	static struct mqtt_utf8 user_name;

	password.utf8 = (uint8_t*)pass;
	password.size = strlen(pass);
	user_name.utf8 = (uint8_t*)user;
	user_name.size = strlen(user);

	/* Initializes the client instance. */
	mqtt_client_init(client);

	/* Resolves the configured hostname and initializes the MQTT broker structure */
	err = broker_init();
	if (err) {
		LOG_ERR("Failed to initialize broker connection");
		return err;
	}

	/* MQTT client configuration */
	client->broker = &broker;
	client->evt_cb = mqtt_evt_handler;
	client->client_id.utf8 = client_id_get();
	client->client_id.size = strlen(client->client_id.utf8);
	client->password = &password;
	//client->password = NULL;
	client->user_name = &user_name;		
	client->protocol_version = MQTT_VERSION_3_1_1;

	/* MQTT buffers configuration */
	client->rx_buf = rx_buffer;
	client->rx_buf_size = sizeof(rx_buffer);
	client->tx_buf = tx_buffer;
	client->tx_buf_size = sizeof(tx_buffer);

	/* We are not using TLS */
	client->transport.type = MQTT_TRANSPORT_NON_SECURE;	

	return err;
}

Here are my logs below showing MQTT disconnection.

[00:00:52.251,831] <inf> MQTT_OVER_WIFI: Connecting to MQTT Broker...
[00:00:52.634,246] <inf> MQTT_OVER_WIFI: IPv4 Address found 54.221.205.80
[00:00:52.634,277] <inf> MQTT_OVER_WIFI: MQTT Broker: mqtt.beebotte.com
[00:00:52.634,277] <inf> MQTT_OVER_WIFI: Port: 1883
[00:00:52.894,592] <inf> net_mqtt: Connect completed
[00:00:53.203,857] <err> MQTT_OVER_WIFI: MQTT connect failed: 5
[00:00:53.203,887] <inf> net_mqtt_sock_tcp: Closing socket 7
[00:00:53.208,251] <inf> MQTT_OVER_WIFI: MQTT client disconnected: -111
[00:00:53.208,282] <err> MQTT_OVER_WIFI: Error in mqtt_input: -111
[00:00:53.208,282] <inf> MQTT_OVER_WIFI: Disconnecting MQTT client
[00:00:53.208,312] <err> MQTT_OVER_WIFI: Could not disconnect MQTT client: -128

Is there anything wrong on how I set the MQTT username at code?

Regards,

Markel

Related