[ZBX-20993] Agent2 plugin MQTT: invalid client identifier Created: 2022 May 05 Updated: 2024 Jul 01 Resolved: 2024 Jul 01 |
|
| Status: | Closed |
| Project: | ZABBIX BUGS AND ISSUES |
| Component/s: | Agent2 plugin (G) |
| Affects Version/s: | None |
| Fix Version/s: | 6.0.32rc1, 6.4.17rc1, 7.0.1rc1, 7.2.0alpha1 |
| Type: | Problem report | Priority: | Trivial |
| Reporter: | Benedikt Patt | Assignee: | Eriks Sneiders |
| Resolution: | Fixed | Votes: | 1 |
| Labels: | agent2, mqtt, plugin | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Team: | |
| Sprint: | S24-W24/25 |
| Story Points: | 1 |
| Description |
|
The client identifier of the build in MQTT client looks like this: "Zabbix agent 2 5.4.12 ab-12-cd-34-ef". This does not meet the MQTT specification (see MQTT Version 5.0). It says: The Server MUST allow ClientID's which are between 1 and 23 UTF-8 encoded bytes in length, and that contain only the characters "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ".
If I try to connect to CCU-Jack (mdzio/ccu-jack), the connection is refused with the error "identifier rejected". |
| Comments |
| Comment by Benedikt Patt [ 2024 Mar 01 ] |
|
Is there any progress here? |
| Comment by pascal de jessey [ 2024 Apr 04 ] |
|
Hello,
I've the same problem, been able to correct it manually in the source as I'm needing it. Really quick and dirty correction, in src/go/plugins/mqtt/mqtt.go :
diff --git a/src/go/plugins/mqtt/mqtt.go b/src/go/plugins/mqtt/mqtt.go
index a4aadaced20..3afd7322a12 100644
--- a/src/go/plugins/mqtt/mqtt.go
+++ b/src/go/plugins/mqtt/mqtt.go
@@ -350,7 +350,7 @@ func getClientID() string {
impl.Errf("failed to generate a uuid for mqtt Client ID: %s", err.Error)
return "Zabbix agent 2 " + version.Long()
}
- return fmt.Sprintf("Zabbix agent 2 %s %x-%x-%x-%x-%x", version.Long(), b[0:4], b[4:6], b[6:8], b[8:10], b[10:])
+ return fmt.Sprintf("%x", b[0:10])
}
func hasWildCards(topic string) bool {
Basically just change the ClientId to be an random hexadecimal string of 20 chars length.
Without the modification, I have this error :
2024/04/04 15:58:19.648231 [MQTT] creating client for [tls://mydomain.com:8883] 2024/04/04 15:58:19.648280 [MQTT] creating new subscriber on topic 'mytopic' for [tls://mydomain.com:8883] 2024/04/04 15:58:19.648294 [MQTT] establishing connection to [tls://mydomain.com:8883] 2024/04/04 15:58:20.057157 [MQTT] cannot establish connection to [tls://mydomain.com:8883]: identifier rejected
with the modification :
2024/04/04 16:00:11.278907 [MQTT] creating client for [tls://mydomain.com:8883] 2024/04/04 16:00:11.278978 [MQTT] creating new subscriber on topic 'mytopic' for [tls://mydomain.com:8883] 2024/04/04 16:00:11.278992 [MQTT] establishing connection to [tls://mydomain.com:8883] 2024/04/04 16:00:11.469973 [MQTT] established connection to [tls://mydomain.com:8883] 2024/04/04 16:00:11.470083 [MQTT] connected to [tls://mydomain.com:8883] 2024/04/04 16:00:11.470140 [MQTT] subscribing 'topic' to [tls://mydomain.com:8883] 2024/04/04 16:00:11.500560 [MQTT] subscribed 'topicc' to [tls://mydomain.com:8883]
would be great to have this change in the code for next versions.
|
| Comment by Eriks Sneiders [ 2024 Jun 20 ] |
|
FIXED in
|