MQTT Import - Client ID Problem

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
chumaty
New user
Posts: 7
Joined: 01 Jul 2020, 15:26

MQTT Import - Client ID Problem

#1 Post by chumaty » 01 Jul 2020, 15:35

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" ?
Attachments
mqtt-import.JPG
mqtt-import.JPG (78.8 KiB) Viewed 12941 times

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: MQTT Import - Client ID Problem

#2 Post by grovkillen » 01 Jul 2020, 15:57

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 :idea: :idea: :idea:

chumaty
New user
Posts: 7
Joined: 01 Jul 2020, 15:26

Re: MQTT Import - Client ID Problem

#3 Post by chumaty » 01 Jul 2020, 16:45

grovkillen wrote: 01 Jul 2020, 15:57 It's using the same settings as the controller right?
Sorry, i don't understand what do you mean

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: MQTT Import - Client ID Problem

#4 Post by TD-er » 01 Jul 2020, 17:11

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.

chumaty
New user
Posts: 7
Joined: 01 Jul 2020, 15:26

Re: MQTT Import - Client ID Problem

#5 Post by chumaty » 01 Jul 2020, 18:48

TD-er wrote: 01 Jul 2020, 17:11 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.
ok, senk, i will try

chumaty
New user
Posts: 7
Joined: 01 Jul 2020, 15:26

Re: MQTT Import - Client ID Problem

#6 Post by chumaty » 01 Jul 2020, 19:22

TD-er wrote: 01 Jul 2020, 17:11 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.
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
user_0baf685b_esp_easy.png (122.85 KiB) Viewed 12922 times

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: MQTT Import - Client ID Problem

#7 Post by TD-er » 01 Jul 2020, 23:51

I do... 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;
}
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.

chumaty
New user
Posts: 7
Joined: 01 Jul 2020, 15:26

Re: MQTT Import - Client ID Problem

#8 Post by chumaty » 02 Jul 2020, 08:20

TD-er wrote: 01 Jul 2020, 23:51 I do... 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;
}
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.
It is really strange. But i think that many people use "mosquitto mqtt broker" and him not need unique client id.

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
mqtt-custom.jpg (213.29 KiB) Viewed 12883 times

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: MQTT Import - Client ID Problem

#9 Post by TD-er » 02 Jul 2020, 09:07

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.

chumaty
New user
Posts: 7
Joined: 01 Jul 2020, 15:26

Re: MQTT Import - Client ID Problem

#10 Post by chumaty » 02 Jul 2020, 10:16

TD-er wrote: 02 Jul 2020, 09:07 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.
Sorry, where i can find author this plugin?

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: MQTT Import - Client ID Problem

#11 Post by TD-er » 02 Jul 2020, 10:28

Many people have contributed to this plugin and it seems like the most recent changes on it were done by me.

chumaty
New user
Posts: 7
Joined: 01 Jul 2020, 15:26

Re: MQTT Import - Client ID Problem

#12 Post by chumaty » 02 Jul 2020, 10:41

TD-er wrote: 02 Jul 2020, 10:28 Many people have contributed to this plugin and it seems like the most recent changes on it were done by me.
:(
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').

Post Reply

Who is online

Users browsing this forum: No registered users and 24 guests