Mqtt.connected() in mc60 tinygsm

hi, i am using mc60 gsm module and i want to publish the data using mqtt protocol, but while i am trying to connect it wont connect. may i know the reason, kindly any one help me please.
boolean mqttConnect()
{
SerialMon.print("Connecting to ");
SerialMon.print(broker);

boolean status = mqtt.connect("data", mqttUser, mqttPassword);
if (status == false) {
SerialMon.println(" fail");
return false;
}
else if (status == true)
{
SerialMon.println(" successfully connected");
mqtt.publish("/userDevice", "GsmClientTest started");
//mqtt.subscribe(_notify);
//mqtt.subscribe(_subscribe);
return mqtt.connected();
}
}

this is the mqtt connect function in this function mqtt.connect() returns true but mqtt.connected() always returns false, so i cant publish my data in mqtt.

Might be of help, Using MQTT with the MKR GSM 1400 | Arduino Documentation | Arduino Documentation?

krevedkoman/gsm_mqtt: GSM MQTT AUTOSTART ARDUINO (github.com)

Other sources of how to and so on and so forth can be found by using the words "arduino mqtt gsm" in an internet search engine.

You are not using broker in your connect call, which seems odd.

sorry; before conneting to server i have done
mqtt.setServer(broker, mqttPort);
mqtt.setCallback(mqttCallback);
mqttConnect();
while (!mqtt.connected()) {
SerialMon.println("......Error MQTT");
if (mqtt.connect("data", mqttUser, mqttPassword ))
{
SerialMon.println("connected");
delay(5000);
//mqtt.subscribe(_notify);
// break;
}

}
SerialMon.println("......MQTT CONNECTED");
}

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.