MQTT Import - Client ID Problem
Moderators: grovkillen, Stuntteam, TD-er
MQTT Import - Client ID Problem
Hi!
Please help me, why Plugin "MQTT Import" match random number to Client ID ?
I have config, and I get random Client ID on my MQTT Broker.
Example: first connection to mqtt broker i have client id: "user_0baf685b_esp_easy-Import", next connection or random connection i have "user_0baf685b_esp_easy-Import1", "user_0baf685b_esp_easy-Import2" and ....
How i can set fix client id for "MQTT Import" ?
Please help me, why Plugin "MQTT Import" match random number to Client ID ?
I have config, and I get random Client ID on my MQTT Broker.
Example: first connection to mqtt broker i have client id: "user_0baf685b_esp_easy-Import", next connection or random connection i have "user_0baf685b_esp_easy-Import1", "user_0baf685b_esp_easy-Import2" and ....
How i can set fix client id for "MQTT Import" ?
- Attachments
-
- mqtt-import.JPG (78.8 KiB) Viewed 19522 times
- grovkillen
- Core team member
- Posts: 3621
- Joined: 19 Jan 2017, 12:56
- Location: Hudiksvall, Sweden
- Contact:
Re: MQTT Import - Client ID Problem
It's using the same settings as the controller right?
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you
Re: MQTT Import - Client ID Problem
Sorry, i don't understand what do you mean
Re: MQTT Import - Client ID Problem
MQTT import plugin uses the settings of the first enabled MQTT controller.
In the configuration of that controller, under the header "MQTT" is this checkbox:
Unique Client ID on Reconnect
Make sure it is not checked.
In the configuration of that controller, under the header "MQTT" is this checkbox:
Unique Client ID on Reconnect
Make sure it is not checked.
Re: MQTT Import - Client ID Problem
It is didn't help me.
I turn on my esp and first time i have got "user_0baf685b_esp_easy-Import"
next time i made reboot on ESP, and i have got "user_0baf685b_esp_easy-Import1"
And, if i disable "MQTT Import", reboot ESP and enable "MQTT Import" i have got "user_0baf685b_esp_easy-Import"
I don't understand why?
- Attachments
-
- user_0baf685b_esp_easy.png (122.85 KiB) Viewed 19503 times
Re: MQTT Import - Client ID Problem
I do... now
I checked the source code of the MQTT import plugin and found this:
And that's not how it should be done, or at least not how it is intended to work.
What's intended is what I gave as my initial answer.
What I find surprising is that nobody else complained about it, as this specific piece of code has been unchanged for roughly 2 years now.
I checked the source code of the MQTT import plugin and found this:
Code: Select all
String getClientName() {
//
// Generate the MQTT import client name from the system name and a suffix
//
String tmpClientName = F("%sysname%-Import");
String ClientName = parseTemplate(tmpClientName);
ClientName.trim(); // Avoid spaced in the name.
ClientName.replace(' ', '_');
if (reconnectCount != 0) ClientName += reconnectCount;
return ClientName;
}
What's intended is what I gave as my initial answer.
What I find surprising is that nobody else complained about it, as this specific piece of code has been unchanged for roughly 2 years now.
Re: MQTT Import - Client ID Problem
It is really strange. But i think that many people use "mosquitto mqtt broker" and him not need unique client id.TD-er wrote: ↑01 Jul 2020, 23:51 I do... now
I checked the source code of the MQTT import plugin and found this:And that's not how it should be done, or at least not how it is intended to work.Code: Select all
String getClientName() { // // Generate the MQTT import client name from the system name and a suffix // String tmpClientName = F("%sysname%-Import"); String ClientName = parseTemplate(tmpClientName); ClientName.trim(); // Avoid spaced in the name. ClientName.replace(' ', '_'); if (reconnectCount != 0) ClientName += reconnectCount; return ClientName; }
What's intended is what I gave as my initial answer.
What I find surprising is that nobody else complained about it, as this specific piece of code has been unchanged for roughly 2 years now.
But i use "verneMQ mqtt broker" and him need unique client id.
Tell me. Do you can or command "esp easy" make change in "mqtt import plugin", where can make custom name?
Example: mqtt-custom.jpeg
But if this is not possible, may be you help me, how i can make custom mqtt plugin?
- Attachments
-
- mqtt-custom.jpg (213.29 KiB) Viewed 19464 times
Re: MQTT Import - Client ID Problem
This has to be fixed in the MQTT import plugin, in the function I quoted.
So if you can build it yourself, you can simply change that code and build for yourself.
So if you can build it yourself, you can simply change that code and build for yourself.
Re: MQTT Import - Client ID Problem
Many people have contributed to this plugin and it seems like the most recent changes on it were done by me.
Re: MQTT Import - Client ID Problem
I tested "MQTT Import" on "Mosquitto Broker" and i have got this log (it is really problem):
And i don't know, like change plugin code
May be you know, who it is can made?
1593678432: Received SUBSCRIBE from user_xxx_relayxxx-Import1 <-- I clicked reset button on ESP
1593678432: user_xxx/user_xxx_relayxxx/GPIO12 (QoS 0)
1593678432: user_xxx_relayxxx-Import1 0 user_xxx/user_xxx_relayxxx/GPIO12
1593678432: Sending SUBACK to user_xxx_relayxxx-Import1
1593678432: Received DISCONNECT from user_xxx_relayxxx-Import1
1593678432: Client user_xxx_relayxxx-Import1 disconnected.
1593678432: New client connected from 192.168.100.100 as user_xxx_relayxxx-Import2 (c1, k10, u'user_xxx').
1593678432: Sending CONNACK to user_xxx_relayxxx-Import2 (0, 0)
1593678432: Received SUBSCRIBE from user_xxx_relayxxx-Import2 <-- I clicked reset button on ESP
1593678432: user_xxx/user_xxx_relayxxx/GPIO12 (QoS 0)
1593678432: user_xxx_relayxxx-Import2 0 user_xxx/user_xxx_relayxxx/GPIO12
1593678432: Sending SUBACK to user_xxx_relayxxx-Import2
1593678432: Received DISCONNECT from user_xxx_relayxxx-Import2
1593678432: Client user_xxx_relayxxx-Import2 disconnected.
1593678433: New client connected from 192.168.100.100 as user_xxx_relayxxx-Import3 (c1, k10, u'user_xxx').
1593678433: Sending CONNACK to user_xxx_relayxxx-Import3 (0, 0)
1593678433: Received SUBSCRIBE from user_xxx_relayxxx-Import3 <-- I clicked reset button on ESP
1593678433: user_xxx/user_xxx_relayxxx/GPIO12 (QoS 0)
1593678433: user_xxx_relayxxx-Import3 0 user_xxx/user_xxx_relayxxx/GPIO12
1593678433: Sending SUBACK to user_xxx_relayxxx-Import3
1593678433: Client user_xxx_relayxxx already connected, closing old connection.
1593678433: Socket error on client user_xxx_relayxxx, disconnecting.
1593678433: New client connected from 192.168.100.100 as user_xxx_relayxxx (c0, k10, u'user_xxx').
Who is online
Users browsing this forum: No registered users and 1 guest