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

MQTT connection fails occasionally when using Ethernet connection #9

Open
jozala opened this issue Sep 25, 2019 · 5 comments
Open

MQTT connection fails occasionally when using Ethernet connection #9

jozala opened this issue Sep 25, 2019 · 5 comments
Labels
bug Something isn't working

Comments

@jozala
Copy link
Contributor

jozala commented Sep 25, 2019

PubSubClient gets disconnected from MQTT broker from time to time (time periods differs significantly - from few minutes to couple of hours).

Looks like PubSubClient is sending malformed TCP/MQTT packet which looks like Disconnect Req, but with very high Msg Len. It causes messages afterwards to be treated as continuation of this message. That includes Ping Request message. After "keep alive" timeout (in my case 15sec x2) PubSubClient decides to disconnect as it has not received Ping Response message.

I couldn't find the problem in RoomHub code. It looks like the problem in W5500 hardware or Arduino Ethernet library.

This is important to fix this as it makes using RoomHub with Ethernet connection unstable.
It doesn't influence version with WiFi connection which seems to be stable.

There are tickets created for this issue in PubSubClient and Ethernet library projects:
arduino-libraries/Ethernet#106
knolleary/pubsubclient#639

Ideas to check:

  • try to use other versions of Ethernet library (Adafruit/Wiznet)
  • replace W5500 with other hardware (are pins available?)
  • adding some capacitor in connection
  • use asynchronous MQTT library instead of PubSubClient (https://github.com/marvinroger/async-mqtt-client)
@jozala jozala added the bug Something isn't working label Sep 25, 2019
@MathieuDeprez
Copy link

MathieuDeprez commented Apr 10, 2020

Hi maniekq,
I think that I had the same problem as you. When I was using W5500 with the ESP32, the mqtt doesn't work good. I had a deconnexion every 2s in the worse case and I really don't know where it was coming from ..
I kind of fix the issue by using another W5500 module from a different manufacturer.

Here are both of the modules, (left= don't works, right = works !)
w5500-min

I don't know if you have exactly the same issue but if it can help you, I will be glad !

EDIT

Actually, I was powering a small w5500 in 5V instead of 3.3V and now that I am powering it with the right voltage, it is completely stable.

@jozala
Copy link
Contributor Author

jozala commented Apr 15, 2020

@mathieu56000 Anyway - it is really great you've wrote about it. I was trying with multiple modules with the same results. Maybe I am doing some silly mistake :/ . Now I know it is working for you - it gives me very valuable information.

Could you please give me a couple of pointers?
Do you use ESP32 + W5500 for long running MQTT connection?
How long you've been running ESP32 + W5500 on single connection without any disruption?
Do you power large W5500 with 5V or 3v3? Is it OK to power it with 5V and use it directly with ESP32?

@MathieuDeprez
Copy link

Hi @maniekq ,
For now, the longest connexion was 6h30 and I had just 2 deconnexions but the ESP32 was able to reconnect right after that. (test done with the little W5500, 3.3V) :
image
And I have no proof of that but with the 5V module, I had a 4h connexion without any deconnexion. Both of the module are the same so it is just a matter of chance I think.

It is OK to power them directly with the ESP32 but I think this is the limit in term of power because when I am connecting something else to the ESP32, the W5500 is not working good at all anymore... So it is technically possible but I will not be very confident about that. I am using a AMS1117 (3.3 or 5) regulator module for that, it convert 12V to 3.3V or 5.5V.

Also, I am doing that job for a company and I will soon have to test the stability of the connexion (for more than 6h30) so I will be glad to share my results with you!

@jozala
Copy link
Contributor Author

jozala commented May 13, 2020

Hi @mathieu56000,
Any updates on that? Have you had a chance to do some long running tests one this setup?
I think I will buy some little W5500 if it works stable for you.

@MathieuDeprez
Copy link

MathieuDeprez commented May 19, 2020

Hi @maniekq ,
Unfortunately, not yet but for the short runs (less than a day) that I could test, I noticed that the ESP32 reconnected itself to the MQTT server right after a deconnexion which are very rare.
I also use WiFi in some configuration and for that, I use a MQTT async library which reconnect quickly right after a deconnexion (https://github.com/marvinroger/async-mqtt-client) => Not compatible with the Wiznet I think.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants