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
Library won't reconnect. #18
Comments
Confirmed that the reconnection never works for me. And keepalive also never works. These ruins the library to useless. Otherwise, this library would be nice. It has everything. But these two issues kill everything. I reported the issues for a while. Hope there is a chance to fix them. |
Yeah, agreed. I'm thinking of either going back to the synchronous library, but I'll see if I can sidestep the issues by adding a call every 5 seconds to connect if not connected. |
I tested this with Adafruit IO and also Mosquitto. I remember even I publish every 60 seconds, there will finally a disconnection which breaks the connection permanently until restart.
|
Ouch, the second kills it. I can deal with random disconnections if I have the script try to connect every 10-15 seconds, but if it doesn't even know it's disconnected, that's a no-go... |
I have such a case, after the connection is disconnected permanently until restart. I publish every 60 seconds to server. |
You're right, the library is not stable, that is why it is not actually released as v1. I've never had this kind of issue however. So you experience this behavior with the example sketch, for example? We will obviously try to solve these issues, unfortunately I don't have ESPs at the moment for 2 weeks so I cannot do anything during this timelapse. |
Right! Just tested with Fullfeatured example with Adafruit IO and Mosquitto on PI3. Both have Keepalive and disconnection problem. Once disconnected, there is no way to reconnect until restart. I am using NodeMCU which is actually ESP12E. And all related software/libraries are all updated to the newest version. This library has good potential. Don't give up! I can help if you find something to change. You can tell me what to try if you want. I also tried the library to force re-connection by passing the variable inside the cpp file. It also does not connect. |
I won't give up, don't worry. 😉 Maybe an esp8266/Arduino or me-no-dev/ESPAsyncTCP update changed some things that we will need to figure out. |
For me, with the FullFeatured example, I will have two conditions:
|
You can see my usage here: https://gitlab.com/stavros/sonoff/blob/08ac399becc01eb61666fdaa44c9daabd84d8e04/src/main.ino I also experience disconnections that never reconnect. I have a hunch that |
Can you test #19? |
Will be a fix very soon or i am planing to go with https://github.com/i-n-g-o/esp-mqtt-arduino |
The thing is I am not able to reproduce... I've been running a sample sketch for 72 hours, publishing at different rates, and no disconnection so far. So I am kind of stuck! |
When I restart my mosquitto instance, it reconnects just fine. I am pretty sure of the answer, but you're all using a modern mosquitto broker, right? I am using v1.4.9. |
I'm using 1.4.8 :/ Too bad you can't reproduce this, it happened pretty regularly for me (disconnection after a few days, without reconnection). |
Right, I use everything (Arduino IDE, EPS8266 library, ESPAsyncTCP, On Wed, Aug 17, 2016 at 3:23 AM, Marvin Roger notifications@github.com
|
I'm using mosca, i think this is not related with broker. maybe we all use ESPAsyncWebServer except @marvinroger |
It may not be MQTT broker issue. The problem exists for both Adafruit IO and Mosquitto broker. |
I switched the exact same code from async MQTT client to the normal, synchronous MQTT client and reconnections work fine. |
@kiralikbeyin said he was using ESPAsyncWebServer, are you @skorokithakis and @eos1d3? As it uses the same underlying ESPAsyncTCP, there might be a conflict or something. |
Not that I know of. This is my code: https://gitlab.com/stavros/sonoff/blob/08ac399becc01eb61666fdaa44c9daabd84d8e04/src/main.ino |
Should be a DNS problem |
I use this: https://github.com/me-no-dev/ESPAsyncTCP I did try two versions of the above in July, both have the same problem. One thing I cannot confirm, when I tested this library for the first time (at the time you released it), I remember I see a lot of disconnection and reconnection. Then after changes of this and that, it never works now. |
Are you all using hostnames instead of direct IP? |
I'm using a hostname, yes. You think resolution is failing? |
I use Mosquitto broker on PI3 at home with IP (192.168.2.xxx). It never works! |
mqttClient.setServer(IPAddress(172, 20, 10, 7), 1883); |
It can't be DNS problem as it can connect, public and subscribe normally for a while and then die. |
@marvinroger What is the date of your ESPAsyncTCP library? |
@me-no-dev Wait! Why is my version different from the above?
And it starts on line 359. |
i pushed some commits since, but nothing important :) |
Waiting for exception, it takes time. |
I changed this for NULL checking.
It has been a while and I still cannot see any exception. |
can't be timing :) this function is called by lwip when there is result. Interesting though... I hope you get the same exception so we figure out what is going on. |
It was easy to get exceptions before . But now I still can't get one. |
Finally got it!
|
what do you guys think is the best way to handle this case? call onDisconnect? |
Pls explain to me the cause. onDisconnect is called twice to cause the problem? |
please pull the latest version of ESPAsyncTCP. It will call onError and onDisconnect in the case where DNS returns empty result (could not resolve the host). |
I think |
many users might not attach to onError as it always leads to disconnect afterwards. I'm worried that they might miss the failure. |
Makes sense. We can workaround this anyway, at the application level. ;) Alright, let's wait for @eos1d3 feedback, so we can close both issues here and on ESPAsyncTCP! |
Just tell me what you want me to do. |
not get exception :) |
@marvinroger Will you update your example so that we can confirm it works? And this saves time to test again for example. |
There's nothing to chance, as @me-no-dev handled a DNS error the same way a normal failure would happen, so it would reconnect anyway. Nothing needs to change in the example :) just pull the latest ESPAsyncTCP git and check if there are no exceptions anymore. |
OK. I will test it for at least one day. Will inform again if I find error. BTW, is there any timeout setting in ESPAsyncTCP? And what is the default timeout? |
there is 5 seconds timeout between the time you send data and get an ACK from the other side. It's used to detect lost connection and calls onTimeout |
When proxy or VPN is used, using 5 seconds may not be safe enough. And in some countries, like China, the internet is very slow to reach outside from China. I suggest giving an option for custom timeout setting. |
maybe look at the header? https://github.com/me-no-dev/ESPAsyncTCP/blob/master/src/ESPAsyncTCP.h#L131 |
ah nevermind... i see that I use the defined value here: https://github.com/me-no-dev/ESPAsyncTCP/blob/master/src/ESPAsyncTCP.cpp#L309 |
It has been running for 15 hrs without any error with disconnection of 60 seconds intervals. This issue can be closed. Great work! Thanks! @me-no-dev Is |
Awesome, kudos @me-no-dev :) |
@eos1d3 you wait for ack only when you are sending a packet. RxTimeout deals with time since last incoming transmission (in cases where you want to close a connection if nothing has been received for some time) |
Hi There, Seem to have the same issue with my setup trying to connect to Adafruit IO. Connecting, disconnecting with error code 0 and 6. Can somebody summarise how to fix the issue? Do I need to apply fix to ESPAsyncTCP? Thanks for helping out.... Using v1.0.0. ESP AsyncTCP library R |
I have the library set to reconnect on disconnection, but that doesn't work, and I find the clients frequently disconnected even though they are on WiFi. Is there a setting I can use, or another way I can make them keep trying to reconnect?
The text was updated successfully, but these errors were encountered: