How to set ClientID fo MQTT.

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
MarkIngle
Normal user
Posts: 47
Joined: 10 Feb 2016, 05:06

How to set ClientID fo MQTT.

#1 Post by MarkIngle » 13 Feb 2016, 13:57

I am not able to connect to my MQTT broker (Mosquitto). But it appears to be related to the clientid setting in the ESP EASY code. The following message is being displayed in the serial monitor:

INIT : Booting Build nr:78
WIFI : Connecting... 1
WIFI : Connected!
INIT : I2C
MQTT : Failed to connected to broker
MQTT : Failed to connected to broker

INIT : Boot OK
INIT : Normal boot

I found the following code that is generating the error message:

// MQTT needs a unique clientname to subscribe to broker
String clientid = "ESPClient";
clientid += Settings.Unit;
String subscribeTo = "";
.
.
if (MQTTresult)
{
log = F("MQTT : Connected to broker");
addLog(LOG_LEVEL_INFO, log);
subscribeTo = Settings.MQTTsubscribe;
subscribeTo.replace("%sysname%", Settings.Name);
MQTTclient.subscribe(subscribeTo);
log = F("Subscribed to: ");
log += subscribeTo;
addLog(LOG_LEVEL_INFO, log);
break; // end loop if succesfull
}
else
{
log = F("MQTT : Failed to connected to broker");
addLog(LOG_LEVEL_ERROR, log);

Is it possible to change the clientid within ESP Easy?
Last edited by MarkIngle on 18 Feb 2016, 03:45, edited 1 time in total.

MarkIngle
Normal user
Posts: 47
Joined: 10 Feb 2016, 05:06

Re: How to set ClientID fo MQTT....

#2 Post by MarkIngle » 14 Feb 2016, 20:55

I was way off on posting this entry. Sorry if I confused anyone...the answer to my problem can be found here:

http://www.esp8266.nu/forum/viewtopic.php?f=6&t=813

tozett
Normal user
Posts: 734
Joined: 22 Dec 2015, 15:46
Location: Germany

Re: How to set ClientID fo MQTT....

#3 Post by tozett » 14 Feb 2016, 21:18

MarkIngle wrote: INIT : Booting Build nr:78

// MQTT needs a unique clientname to subscribe to broker
String clientid = "ESPClient";
clientid += Settings.Unit;

Is it possible to change the clientid within ESP Easy?
looks if the question is for the devs...
as long as this is in the code this way...:
clientid += Settings.Unit;

MarkIngle
Normal user
Posts: 47
Joined: 10 Feb 2016, 05:06

Re: How to set ClientID fo MQTT....

#4 Post by MarkIngle » 14 Feb 2016, 21:24

Yeah the code is fine....I am just learning and misunderstood the root of my problem. This post can be deleted.

Post Reply

Who is online

Users browsing this forum: No registered users and 17 guests