knolleary / pubsubclient

A client library for the Arduino Ethernet Shield that provides support for MQTT.
http://pubsubclient.knolleary.net/
MIT License
3.78k stars 1.46k forks source link

ESP32 TTGO v1 cannot conect to mosquitto MQTT broker hosted by windows #985

Closed miguelbidarra closed 1 year ago

miguelbidarra commented 1 year ago

Hello everyone! I've been struggling with this issue for quite a while and I can't seem to understand how to fix it. I'm using an ESP32 TTGO OLED v1 to send temperature information through mosquitto MQTT to be displayed in node red, being the MQTT broker and node red hosted by my computer which is running windows 10. As you can see in my code, I'm connecting my ESP to the WiFi (yes I change the password to the "real" password not the three dots) and then to the PC IP (192.168.1.74) which corresponds to the MQTT broker IP. Although node-red connects to the broker as you can see in the images, the ESP32 refuses to establish connection. Can someone help me find the solution to this problem?

This is the error I get from ESP: Attempting MQTT connection...failed, rc=-2 try again in 5 seconds

I've aso tried to allow listeners on the mosquitto.conf file and allow_anonymous but it is irrelevant as it continues to print out this error.

dashboard esp_error mosquitto node-red wif

I'm a bit desperate cause I've searched all the internet, all issues and none of the solutions fit my case. Thank you everyone :)

miguelbidarra commented 1 year ago

.

Veccoy commented 4 months ago

Hello, I may have the same problem. How did you solve it ?