marvinroger / async-mqtt-client

📶 An Arduino for ESP8266 asynchronous MQTT client implementation
MIT License
835 stars 266 forks source link

MQTT broker autentication #300

Closed 100000watt closed 9 months ago

100000watt commented 10 months ago

Hi, How do I enter my username and password to authenticate to the broker Mosquitto? AsyncMqttClient.setCredentials always returns error. Forgive me, I'm a novice. Thank you

mtsSwitzerland commented 9 months ago

For me this works

void connectToMqtt() { if (setupInfo == true) { Serial.println("Connecting to MQTT..."); } if (mqttUser && mqttPassword) { mqttClient.setCredentials(mqttUser, mqttPassword); } mqttClient.connect(); }