-
Notifications
You must be signed in to change notification settings - Fork 104
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
ECONNRESET (Connection reset by peer) #5
Comments
Cannot reproduce the error. Using mosquitto_sub and mosquitto_pub I can connect and disconnect (from my laptop) without any obvious problem. What exactly is your test-setup with paho.mqtt.android (or another client with problems)? |
Thanks for your reply. I builded the example project that they provided (only disconnect() function called on onDestroy method, ip and port changed also ofcourse) : The log output from client side was written in first message. I can record video or prepare sample mobile app for you in case you need. |
Hello. I also encountered such a problem. The error is saved before the uMQTTBroker reboot. |
Solved a problem: |
It did not work long :( |
Could you send me the client's code? Guess, it has to do with session handling. For some reason the server rejects the CONN request (probably, because the session is still there?) |
#include <PubSubClient.h> // Update these with values suitable for your network. const char* ssid = "AU_01_WiFi"; long lastReconnectAttempt = 0; WiFiClient espClient; void setup() { void setup_wifi() { delay(10); WiFi.begin(ssid); while (WiFi.status() != WL_CONNECTED) { Serial.println(""); void callback(char* topic, byte* payload, unsigned int length) { // Switch on the LED if an 1 was received as first character void reconnect() { void loop() { client.loop(); long nowT = millis(); } |
I think, it could be the same problem. What do you think, is it the same problem ? Here is the video and the sample app :
|
Thanks - probably it is the same problem - no time today, will try to look into it over the weekend. |
Thank you. I would be very grateful if I can get rid of this problem. |
Think, I found the problem. Introduced it, when trying to fix issue #3 It failed to clean up old sessions from the same client. Should be fixed now... |
Thank you, it's getting better. Now after reboot it is stably connected from the second time: https://image.prntscr.com/image/8HFba0bRQaauzAEEUYBQoQ.png If the client uses "client.disconnect ();", then the connection does not exist. |
Dies Not existiert means does not work?
Am 22. Januar 2018 05:58:15 schrieb MasyaShu <notifications@github.com>:
… Thank you, it's getting better. Now after reboot it is stably connected
from the second time:
https://image.prntscr.com/image/8HFba0bRQaauzAEEUYBQoQ.png
If the client uses "client.disconnect ();", then the connection does not exist.
--
You are receiving this because you commented.
Reply to this email directly or view it on GitHub:
#5 (comment)
|
Now the client turns on, sends a message and falls asleep, after 5 seconds wakes up, sends a message again. After he wakes up the connection to the broker occurs at the second attempt. |
After it increased the sleep time (30 seconds), it started from the first time: https://image.prntscr.com/image/calH1rC2SZaT7mbgo8P1Lw.png |
Same result for me. Same error occurred, which could be seen in the video that I send. |
Let me try to understand the setup:
|
|
Tried to reproduce the problem, somewhat hard... With the ESP as AP and IoT MQTT Dashboard (https://play.google.com/store/apps/details?id=com.thn.iotmqttdashboard) as sample client on Android it just works fine. Pubsubclient on the AP for me doesn't even try to connect... (I don't see any TCP connect request on the ESP). Could you help me an try the following on you setup: 40: #undef MQTT_INFO And add This enables debug output in the MQTT server. The output might give some insight into what's going on... |
Starting MQTT broker На клиенте: |
If ESP does not go to sleep, and you use "client.disconnect ()", then on the client: On the broker: |
If you do not use "client.disconnect ();" and to fill the client for 30 seconds, it works without fail. It also works without fail if the device is connected to a broker and is no longer disconnected. |
Even when another client is connected, the second client can not connect: Error: -2: MQTT_CONNECT_FAILED - the network connection failed |
Thanks for your interest. Here is the log output :
And here is the screen capture that I uploaded from the program that you suggested :
|
Thanks for the input. I reworked the logic of disconnection. Now your sample works just fine, even with client.disconnect() for me... |
Thank you, I updated it with your latest committed source. But sadly result is same :(
|
For me, it seems to work...
|
According to your log you are using user/password - maybe that is the reason here, why you get a reject of the connect request? |
Thanks, it works!
Another digression, for a long time struggled with the error rc = -2. Thanks again for your work! |
@martin-ger
I know you are trying to solve this issue for such a unique and brilliant library that no one ever tried to make one so far for ESP. I am grateful for this. Thanks again. |
Thanks for this great work firstly, but I have some problem with it. Let me try to explain it please. I can connect successfully to the broker, and with latest release I can successfully disconnect I suppose. But after a couple of connect-disconnect sequence (usually 4-6) ESP is not accepts new connections. It throws this immediatelly when I try to connect :
Until I restart (power off then on) the ESP, I cannot connect to the mqtt broker from any client on any platform
#using the latest commit of this library as a broker
#using the paho.mqtt.android as a client (tried on other platforms as well, client is not problem I think)
The text was updated successfully, but these errors were encountered: