Skip to content
This repository has been archived by the owner on Jan 6, 2023. It is now read-only.

Error, client state: -1 #56

Closed
alexodus opened this issue Nov 19, 2018 · 15 comments
Closed

Error, client state: -1 #56

alexodus opened this issue Nov 19, 2018 · 15 comments

Comments

@alexodus
Copy link

alexodus commented Nov 19, 2018

in the esp32-mqtt example I obtain always this result. I'm using platformio with platform espressif 32 v1.5.0.

@Gior80
Copy link

Gior80 commented Nov 19, 2018

Your buffer size is too short

@alexodus
Copy link
Author

When I print MQTT_MAX_PACKET_SIZE it's 512. Is not enough?

@Gior80
Copy link

Gior80 commented Nov 19, 2018

No , go to 1024 or 2048

@alexodus
Copy link
Author

the same problem with 2048 also! :(

@alexodus
Copy link
Author

alexodus commented Nov 21, 2018

1024 or 2048 for MQTT_MAX_PACKET_SIZE produce the same error (also directly into the CloudIoTCoreMQTTClient.h file and print the value on serial in order to verify that it's ok) .

@gguuss
Copy link
Contributor

gguuss commented Nov 21, 2018

This could also be caused by incorrect configuration. Maybe try eliminating one of the variables and use one of the HTTP examples; if it doesn't work with HTTP, it definitely won't work with the MQTT. Also, if you're using the library from before 1.0.4, there was a bug where the JWT was not correctly getting generated, try updating the library too.

@alexodus
Copy link
Author

alexodus commented Nov 22, 2018

I used the last version (1.0.5) for my test with 1024 and 2048 buffer size. I'm working on ESP32 and there isn't http example for it. I'm in wrong?

@Gior80
Copy link

Gior80 commented Nov 22, 2018

Alessandro,

Try to change size directly on pubsubclient configuration file . Btw also look at mqtt error codes , you can find a good tables of it on lwmqtt arduino repository

@alexodus
Copy link
Author

alexodus commented Nov 22, 2018

Alessandro,

Try to change size directly on pubsubclient configuration file .

WOW! Now with 1024 (with 2048 esp32 go in bootloop) on file pubsubclient.h I have this:
Error, client state: 5
Ergo MQTT_CONNECT_UNAUTHORIZED

A big step forward! :P

@gguuss
Copy link
Contributor

gguuss commented Nov 22, 2018

@alexodus Try out my branch with the Esp32-lwmqtt example, I find it simpler.

@gguuss
Copy link
Contributor

gguuss commented Nov 22, 2018

@alexodus the esp32-ssd1306 example is HTTP, probably could use a rename ^_^.

@alexodus
Copy link
Author

SOLVED! I had only set MQTT_MAX_PACKET_SIZE more than 324 into pubsubclient.h (I don't like it but I think this is a platformio problem). MQTT_CONNECT_UNAUTHORIZED happen because I modified the private key for test :P

@alexodus
Copy link
Author

Best solution for platformio: add this line on platformio.ini file
build_flags = -DMQTT_MAX_PACKET_SIZE=384
see this issue on pubsubclient library

@gguuss
Copy link
Contributor

gguuss commented Nov 23, 2018

Ahh, thank you @alexodus may be worth adding to the readme, if you want me to do it, happy to accept an issue, if you want to make a PR, happy to review.

@gguuss
Copy link
Contributor

gguuss commented Nov 27, 2018

Added note to the readme, thanks for the errata!

@gguuss gguuss closed this as completed Nov 27, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants