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

esp_mqtt: lwmqtt_connect: -5 with mosquitto broker #9

Closed
donatoaz opened this issue Mar 24, 2018 · 1 comment
Closed

esp_mqtt: lwmqtt_connect: -5 with mosquitto broker #9

donatoaz opened this issue Mar 24, 2018 · 1 comment

Comments

@donatoaz
Copy link

Hi, first off, thanks so much for the work, it is much appreciated.

I managed to get this library to work with the shiftr.io MQTT broker and now I wanted to use my own broker, however I keep getting this error when I try and connect:

I (19834) esp_mqtt: esp_mqtt_process: begin connection attempt
E (20094) esp_mqtt: lwmqtt_connect: -5
W (20094) esp_mqtt: esp_mqtt_process: connection attempt failed

And on the mosquitto log, it shows:

mqtt    | 1521896205: New connection from 177.97.217.166 on port 1883.
mqtt    | 1521896205: Socket error on client <unknown>, disconnecting.

How can I debug this? It seems error -5 is: LWMQTT_NETWORK_FAILED_READ

It it works with shiftr.io brokers, it must be some broker-side configuration I need to change... My mosquitto.conf file is very simple:

pid_file /var/run/mosquitto.pid

persistence false
persistence_location /mqtt/data/

user mosquitto
allow_anonymous true

# Port to use for the default listener.
port 1883

log_dest file /mqtt/log/mosquitto.log
log_dest stdout

include_dir /mqtt/config/conf.d
@donatoaz
Copy link
Author

Using Wireshark I was able to get some relevant info and solve the issue. Apparently, I was sending a user and password on the connection packet and the broker was not happy with that. After changing the code not to send any user or password data it worked.

I know it is a stupid thing, but it would have been nice if the mqtt broker would send back something in the likes of a 403 http, saying it's something related to credentials. Or am I completely off?

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