Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot connect to MQTT broker running on the same ESP32 (PicoMQTT) #1068

Open
fredlcore opened this issue Nov 23, 2024 · 0 comments
Open

Cannot connect to MQTT broker running on the same ESP32 (PicoMQTT) #1068

fredlcore opened this issue Nov 23, 2024 · 0 comments

Comments

@fredlcore
Copy link

fredlcore commented Nov 23, 2024

I have PubSubClient running fine on an ESP32 which connects without any problems to an MQTT broker in my local network.
For my project, I now want to include an MQTT broker in my code on the same ESP32 that PubSubClient is running on, so that users have the choice of using a dedicated MQTT broker or - if my project is the only one they need MQTT for - use a small MQTT broker on the same ESP32. For that I have included PicoMQTT. I can connect to the PicoMQTT broker on that same ESP32 that PubSubClient is running on from MQTT Explorer and publishing and subscribing the topics from outside the ESP32 works fine. PubSubClient is also still running fine when subscribing and publishing to an external MQTT broker, but what is not working is for PubSubClient to connect to the PicoMQTT broker.

I have used the actual local IP, as well as 127.0.0.1 as well as "localhost" to tell PubSubClient that it should connect to the broker on the same host, but the connection fails all the time. state() returns -2 which means that the connection has failed.

Does anyone have an idea why this is the case? I don't want to switch to PicoMQTT for the client functions because it only runs on ESPs, not on the Arduino Due which is also used by a number of my users. Adding an optional feature such as the broker would be fine to offer for just the ESP users.

Any help is highly appreciated!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant