Repository: minio/minio (language: go)

Issue:
Error: mc config set notify_mqtt: identifier rejected
<!--- Provide a general summary of the issue in the Title above -->

## Expected Behavior
<!--- If you're describing a bug, tell us what should happen -->


minio server running in kubernetes should allow for setting up Mosquitto/MQTT notifications. Mosquitto running in cluster with anonymous authentication. I get **identifier rejected** error as shown below. I am able to connect to MQTT broker using mosquitto_pub/sub utilities from remote nodes.


mc admin config set local/ **notify_mqtt:minio** url="tcp://mosquitto.develop.svc.cluster.local:1883"  queue_dir="" queue_limit="0" reconnect_interval="0s"   qos="1" topic="minio" --debug
mc: <DEBUG> PUT /minio/admin/v3/set-config-kv HTTP/1.1
Host: develop-hl.develop.svc.cluster.local:9000
User-Agent: MinIO (linux; amd64) madmin-go/0.0.1 mc/RELEASE.2021-12-20T23-43-34Z
Content-Length: 190
Authorization: AWS4-HMAC-SHA256 Credential=ff2821f6-a466-4270-be51-3a7442cc7fff/20211226//s3/aws4_request, SignedHeaders=host;x-amz-content-sha256;x-amz-date, Signature=**REDACTED**
X-Amz-Content-Sha256: b61b8ab0fca9fa8f41b11cf811e2210771d8eb3912557c5f6372e1f3a9584517
X-Amz-Date: 20211226T210405Z
Accept-Encoding: gzip

mc: <DEBUG> HTTP/1.1 400 Bad Request
Content-Length: 190
Accept-Ranges: bytes
Content-Security-Policy: block-all-mixed-content
Content-Type: application/json
Date: Sun, 26 Dec 2021 21:04:06 GMT
Server: MinIO
Strict-Transport-Security: max-age=31536000; includeSubDomains
Vary: Origin
Vary: Accept-Encoding
X-Amz-Request-Id: 16C469F07C5E3070
X-Content-Type-Options: nosniff
X-Xss-Protection: 1; mode=block

{"Code":"XMinioAdminConfigBadJSON","Message":"identifier rejected","Resource":"/minio/admin/v3/set-config-kv","RequestId":"16C469F07C5E3070","HostId":"acf38cbe-5ea1-412d-b6a6-57c9fb265e0e"}
mc: <DEBUG> Response Time:  204.61687ms

mc: <ERROR> Unable to set 'notify_mqtt:minio url=tcp://mosquitto.develop.svc.cluster.local:1883 queue_dir= queue_limit=0 reconnect_interval=0s qos=1 topic=minio' to server: identifier rejected
 (0) admin-config-set.go:131 cmd.mainAdminConfigSet(..)
 Commit:0b2f0c9b4889 | Release-Tag:RELEASE.2021-12-20T23-43-34Z | Host:secret-test-pod | OS:linux | Arch:amd64 | Lang:go1.17.5 | Mem:69 MB/86 MB | Heap:69 MB/75 MB.

<!--- If you're suggesting a change/improvement, tell us how it should work -->

## Current Behavior
<!--- If describing a bug, tell us what happens instead of the expected behavior -->
Cannot use mc config to setup MQTT notify_mqtt using Mosquitto latest. Changed to nanomq/nanomq:0.5.5-slim and setting up notifications worked !!

<!--- If suggesting a change/improvement, explain the difference from current behavior -->

## Possible Solution
<!--- Not obligatory, but suggest a fix/reason for the bug, -->
Don't waste too much time on Mosquitto latest version as of Dec 26, 2021
<!--- or ideas how to implement the addition or change -->
Use different broker such as nanomq/nanomq:0.5.5-slim
## Steps to Reproduce (for bugs)
<!--- Provide a link to a live example, or an unambiguous set of steps to -->
<!--- reproduce this bug. Include code to reproduce, if relevant -->
<!--- and make sure you have followed https://github.com/minio/minio/tree/release/docs/debugging to capture relevant logs -->

1.
2.
3.
4.

## Context
<!--- How has this issue affected you? What are you trying to accomplish? -->
Setup notifications for minio using the latest Mosquitto MQTT 
<!--- Providing context helps us come up with a solution that is most useful in the real world -->

## Regression
<!-- Is this issue a regression? (Yes / No) -->
<!-- If Yes, optionally please include minio version or commit id or PR# that caused this regression, if you have these details. -->

## Your Environment
<!--- Include as many relevant details about the environment you experienced the bug in -->
* Version used (`minio --version`): Version: 2021-11-09T03:21:45Z

* Server setup and configuration:

mc admin info local
●  develop-ss-0-0.develop-hl.develop.svc.cluster.local:9000
   Uptime: 4 hours 
   Version: 2021-11-09T03:21:45Z
   Network: 4/4 OK 
   Drives: 1/1 OK 

●  develop-ss-0-1.develop-hl.develop.svc.cluster.local:9000
   Uptime: 4 hours 
   Version: 2021-11-09T03:21:45Z
   Network: 4/4 OK 
   Drives: 1/1 OK 

●  develop-ss-0-2.develop-hl.develop.svc.cluster.local:9000
   Uptime: 4 hours 
   Version: 2021-11-09T03:21:45Z
   Network: 4/4 OK 
   Drives: 1/1 OK 

●  develop-ss-0-3.develop-hl.develop.svc.cluster.local:9000
   Uptime: 4 hours 
   Version: 2021-11-09T03:21:45Z
   Network: 4/4 OK 
   Drives: 1/1 OK 

1.7 GiB Used, 2 Buckets, 4 Objects
4 drives online, 0 drives offline

* Operating System and version (`uname -a`):

Linux develop-ss-0-1 5.4.0-91-generic #102-Ubuntu SMP Fri Nov 5 16:31:28 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux


Discussion / hints:

Fix patch:
diff --git a/go.mod b/go.mod
index 947517e7a8854..ac93af9da5c85 100644
--- a/go.mod
+++ b/go.mod
@@ -23,7 +23,7 @@ require (
 	github.com/djherbis/atime v1.0.0
 	github.com/dswarbrick/smart v0.0.0-20190505152634-909a45200d6d
 	github.com/dustin/go-humanize v1.0.0
-	github.com/eclipse/paho.mqtt.golang v1.3.0
+	github.com/eclipse/paho.mqtt.golang v1.3.5
 	github.com/elastic/go-elasticsearch/v7 v7.12.0
 	github.com/fatih/color v1.13.0
 	github.com/go-ldap/ldap/v3 v3.2.4
diff --git a/go.sum b/go.sum
index 5268cb77cd778..80c5f641f3762 100644
--- a/go.sum
+++ b/go.sum
@@ -333,8 +333,8 @@ github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21 h1:YEetp8
 github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1:+020luEh2TKB4/GOp8oxxtq0Daoen/Cii55CzbTV6DU=
 github.com/eapache/queue v1.1.0 h1:YOEu7KNc61ntiQlcEeUIoDTJ2o8mQznoNvUhiigpIqc=
 github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I=
-github.com/eclipse/paho.mqtt.golang v1.3.0 h1:MU79lqr3FKNKbSrGN7d7bNYqh8MwWW7Zcx0iG+VIw9I=
-github.com/eclipse/paho.mqtt.golang v1.3.0/go.mod h1:eTzb4gxwwyWpqBUHGQZ4ABAV7+Jgm1PklsYT/eo8Hcc=
+github.com/eclipse/paho.mqtt.golang v1.3.5 h1:sWtmgNxYM9P2sP+xEItMozsR3w0cqZFlqnNN1bdl41Y=
+github.com/eclipse/paho.mqtt.golang v1.3.5/go.mod h1:eTzb4gxwwyWpqBUHGQZ4ABAV7+Jgm1PklsYT/eo8Hcc=
 github.com/edsrzf/mmap-go v1.0.0/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaBNrHW5M=
 github.com/elastic/go-elasticsearch/v7 v7.12.0 h1:j4tvcMrZJLp39L2NYvBb7f+lHKPqPHSL3nvB8+/DV+s=
 github.com/elastic/go-elasticsearch/v7 v7.12.0/go.mod h1:OJ4wdbtDNk5g503kvlHLyErCgQwwzmDtaFC4XyOxXA4=
diff --git a/internal/event/target/mqtt.go b/internal/event/target/mqtt.go
index d9c04bc625e72..0448a383f6e43 100644
--- a/internal/event/target/mqtt.go
+++ b/internal/event/target/mqtt.go
@@ -209,8 +209,12 @@ func NewMQTTTarget(id string, args MQTTArgs, doneCh <-chan struct{}, loggerOnce
 		args.MaxReconnectInterval = 10 * time.Minute
 	}
 
+	if args.KeepAlive == 0 {
+		args.KeepAlive = 10 * time.Second
+	}
+
 	options := mqtt.NewClientOptions().
-		SetClientID("").
+		SetClientID(id).
 		SetCleanSession(true).
 		SetUsername(args.User).
 		SetPassword(args.Password).


Test patch: