Closed mfechner closed 1 year ago
That's an interesting issue. Are you trying to connect a picomqtt client to a picomqtt broker or are you using a different broker like mosquuitto? Can you share the config?
I tested it against an iobroker having the mqtt adapter installed, it is all standard. The PicoMQTT client is very simple:
setup() {
...
PicoMQTT::Client mqttClient(
MQTT_CLIENT_HOST,
MQTT_CLIENT_PORT,
MQTT_CLIENT_CLIENT_ID,
MQTT_CLIENT_USERNAME,
MQTT_CLIENT_PASSWORD);
...
mqttClient.begin();
...
}
loop() {
...
mqttClient.loop();
...
}
and in the loop just:
Serial.printf("Forward topic '%s': %s\n", topic, payload);
mqttClient.publish(topic, payload);
After removing the ;
from the password it is working fine.
I have also an MQTT broker running on the server, that is using the same credentials like the client (here the ;
is working perfectly fine).
I also tested it with a Shelly3EM to the MQTT module in iobroker and there the ;
is working fine.
IOBroker was logging the correct password and username, but the authentication was not successful. No idea what could be the reason.
If you like, I can also install a mosquitto to see if auth against it also fails with a ;
in the password, if you like.
A test with Mosquitto would be very helpful, but first double check if MQTT_CLIENT_PASSWORD
defined correctly.
Semicolons are interpreted specially in many contexts -- they separate commands in the shell (e.g. bash
) and begin comments (e.g. in platformio.ini
).
If you're unsure, feel free to share the config file/script where MQTT_CLIENT_PASSWORD
's value is defined.
With mosquitto it is working. So we need to understand what iobroker is doing here different.
I'm not familiar with iobroker, but I found Mosquitto to be more forgiving in case of protocol errors. It sometimes accepts connections and traffic even if it doesn't have to according to the protocol spec. Maybe it is the case here too.
Try capturing traffic and comparing the mqtt handshakes with Wireshark. Check for differences in the CONNECT packet and check the CONNACK that is sent in reply, especially check the connection reply code.
It can look a bit cryptic, so feel free to share the captured days and I will try to help analyze it.
@mlesniew I prepared now everything, set again the password to test;test123
on iobroker mqtt broker and I do not really understand, but now it is working. The esp32 with PicoMQTT does now work and also the Shelly3EM works.
I also compared the captures between the shelly and the PicoMQTT client and the only difference I saw was that the shelly is setting a will topic.
So I'm really sorry for opening the issue here, maybe I had some unwanted code on the esp32 or the iobroker need a reboot that fixed something internal in there mqtt broker engine.
I will close the issue for now, sorry for the noise and thanks a lot for your support and for the lib. My idea is integrate the zero feed-in feature in opendtu or I will make a fork if the do not accept that contribution.
Currently I search for components I can use for this ;)
No worries, great that it works for you now. Good luck with your project!
Configure a broker with username and password where the password contains a
;
liketest;test1
.You cannot connect PicoMQTT to the broker.