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

Error on connect code -2 #41

Open
unixpapers opened this issue Dec 12, 2015 · 1 comment
Open

Error on connect code -2 #41

unixpapers opened this issue Dec 12, 2015 · 1 comment

Comments

@unixpapers
Copy link

Hi!

Version: Arduino IDE 1.6.6 (and test 1.6.5), Arduino ESP8266 (2.0.0) when try to connect error -2.
Try use anonymous too. Used tcpdump on Mosquitto server packages have. Have any ideas?

WiFi connected
IP address:
192.168.1.3
Attempting MQTT connection...failed, rc=-2 try again in 5 seconds
Attempting MQTT connection...failed, rc=-2 try again in 5 seconds

@glen442
Copy link

glen442 commented Mar 15, 2016

For your info - from PubSubClient.h:

// Possible values for client.state()
#define MQTT_CONNECTION_TIMEOUT -4
#define MQTT_CONNECTION_LOST -3
#define MQTT_CONNECT_FAILED -2
#define MQTT_DISCONNECTED -1
#define MQTT_CONNECTED 0
#define MQTT_CONNECT_BAD_PROTOCOL 1
#define MQTT_CONNECT_BAD_CLIENT_ID 2
#define MQTT_CONNECT_UNAVAILABLE 3
#define MQTT_CONNECT_BAD_CREDENTIALS 4
#define MQTT_CONNECT_UNAUTHORIZED 5

So your error seems to be that your connection has failed.
This might be because of a connection problem (worth checking), or that the broker you are trying to connect to is on a different port/path.

I had a similar problem connecting to the Adafruit broker, but it turns out I wasn't building the 'topic' (path) correctly. So it was acting like there was a problem with the connection (presumably was returning http 400/300 type errors)

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

2 participants