-
Notifications
You must be signed in to change notification settings - Fork 7.4k
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
[D][WiFiClient.cpp:452] connected(): Disconnected: RES: 0, ERR: 128 problem? #1921
Comments
I check old version work setup: Copy this into UserDocuments/Arduino/hardware/espressif/esp32/ |
It is not a solution to use a lib from last year, other problem is the function
invalid arguments '
|
This is still an issue. I've downloaded the latest Arduino Core for ESP32, the newest libraries and I still get this error: |
I find a method that fix this strange behavior... #2345 |
I don't understand where or what. |
Click on #2345 tag and read! void setup() |
|
WiFi.setSleep(false); doesn't help ! |
WiFi.setSleep(false); doesn't help ! D][WiFiClient.cpp:463] connected(): Disconnected: RES: 0, ERR: 128
All files exists, and works if I open them individually. To check this, add to SPIFFS in /js this JS files, and to /css the css files
not all src's are loaded. Accessing /js/FILENAME, everything works correctly
or
index file is set for load as |
Since these files are loading all at the same time, you may be hitting SPIFFS max open files limit. I saw similar behavior in my project. Firefox re-requests the files in that case, so it only slowed down the page loading for me. Try using Firefox if you're not already using it and see if it makes any difference. |
Interesting that my esp8266 is managing this situation without any problem. |
Same issue... |
Same problem here, but with the MQTT client, it just freezes and the Debug just shows "[D][WiFiClient.cpp:463] connected(): Disconnected: RES: 0, ERR: 128" I think it's something related with the WifiClient. Any news guys? |
WiFi.setSleep(false); after wifi.begin() help me eliminate appearing phantom client that block client parsing (with free buffer). Any way simple examples with wifi on ESP32 today get topic problem if not add WiFi.setSleep(false) in their setup. Probably this solving only masked initial cause of problem. |
@nae9 can you please describe what exactly happens if you don't call |
See SimpleWiFiServer.ino example from WiFi examples branch: if (client) { // if you get a client, ... If i type WiFi.setSleep(false); after WiFi.begin(), then client.stop() make client==0 and all work fine (as on other platforms). A couple year ago all work fine on ESP32 with no WiFi.setSleep(false); directive, but when WiFiClient was modified to use buffer somebody bugged... |
This issue appears to go a bit deeper than just the sleep param. The read() method doesn't check if the client is still connected thus it may mask the disconnected state until some sort of timeout occurs. This may be a bug in the rxBuf code as it is only checking for bytes to read and not detecting the disconnected state until some timeout inside LwIP. |
Same issue! |
For what it's worth, a few things that I think I have understood about this problem, before hitting a wall:
Not sure, whether this helps any. However at least it offers some insight into why |
I'm seeing the same message with very similar circumstances as you guys, except it's not causing me any issues that I can see - I'm not trying to keep a websocket open. I have two clients connected, and they are able to interact with the http server I'm running. I also appear to only see the message when log level is Debug or Verbose. Http headers look fine in Chrome inspector. Are you all trying to have a websocket stay open? |
@paulhaggard : Yes, the message is harmless in some case, but goes along with a real error in other cases. TLDR: The error occurs, if the ESP is trying to accept a new client, while it has not yet finished writing. Testcase below. I think I have finally narrowed down the conditions when this occurs. Hopefully, this will help in fixing this annoying issue. Below, you'll find a self-contained testcase. Amend So, in combination with what I've written earlier, I think we can conclude the problem is that accepting incoming connections is broken, while data has not yet finished writing. Testcase: #include <WebServer.h>
WebServer server(80);
void handlePage();
void setup() {
Serial.begin (115200);
Serial.setDebugOutput(true);
// Example WIFI setup as an access point. Change this to your needs
WiFi.mode(WIFI_STA);
WiFi.begin("MyNet", "password");
server.on("/", handlePage);
server.begin();
}
void loop() {
server.handleClient();
}
void handlePage() {
server.setContentLength(CONTENT_LENGTH_UNKNOWN);
if(server.method() == HTTP_POST) { // AJAX request
int payload = server.arg("payload").toInt();
Serial.print("Serving payload size: ");
Serial.println(payload);
server.send(200, "text/json", "");
// spread the payload across a couple writes, for a more realistic API use
for(int i = payload / 32; i > 0; --i) {
server.sendContent("xxxxxxx.xxxxxxx.xxxxxxx.xxxxxxx.");
}
for(int i = payload % 32; i > 0; --i) {
server.sendContent("x");
}
} else { // Page load
Serial.println("Serving test page");
server.send(200, "text/html", "");
server.sendContent(
"<!DOCTYPE html>\n"
"<html>\n"
"<body>\n"
"<h2>Connectivity test</h2>\n"
"\n"
"n <input type=\"text\" value=\"4\" id=\"n\"/>\n"
"payload <input type=\"text\" value=\"256\" id=\"payload\"/>\n"
"delay <input type=\"text\" value=\"1000\" id=\"delay\"/>\n"
"<button type=\"button\" onclick=\"document.getElementById('result').clear(); doTest(document.getElementById('n').value, document.getElementById('payload').value, document.getElementById('delay').value);\">Go</button>\n"
"\n"
"<h2>Result</h2>\n"
"<div id=\"result\">No test, yet</div>\n"
"\n"
"<script>\n"
"var results = document.getElementById('result');\n"
"result.update = function(sent, success, error, timeout) {\n"
" this.innerHTML = 'Sent: ' + (this.sent += sent) + ' Successes: ' + (this.successes += success) + ' Errors: ' + (this.errors += error) + ' Timeouts: ' + (this.timeouts += timeout);\n"
"};\n"
"result.clear = function() {\n"
" this.sent = this.successes = this.errors = this.timeouts = 0;\n"
" this.update(0,0,0,0);\n"
"};\n"
"results.clear();\n"
"\n"
"function doTest(n, payload, delay) {\n"
" if(n < 1) return;\n"
" \n"
" var req = new XMLHttpRequest();\n"
" req.timeout = 5000;\n"
" req.onload = function() { document.getElementById('result').update(0, (this.readyState == 4), 0, 0); };\n"
" req.onerror = function() { document.getElementById('result').update(0, 0, 1, 0); };\n"
" req.ontimeout = function() { document.getElementById('result').update(0, 0, 0, 1); };\n"
" results.update(1, 0, 0, 0)\n"
" req.open(\"POST\", \"/?payload=\" + payload, true);\n"
" req.send(\"\");\n"
" \n"
" setTimeout(function() {doTest(n-1, payload, delay)}, delay);\n"
"}\n"
"</script>\n"
"</body>\n"
"</html>\n"
);
}
} |
For what it's worth, I will add that the porting my test case to AsyncTCP / ESPAsyncWebServer (https://github.com/me-no-dev/ESPAsyncWebServer) makes the problem disappear. So that might be both a workaround for the time being, and - hopefully - a hint towards a fix. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
I believe the reason that this report has not received any recent activity is not that it is no longer relevant. However, everything of relevance has already been stated. Please keep it open. |
@xreef so far so fair, but what's your insight regarding the root cause of this issue? |
@cyberman54 ahh ok, sorry. When I have more time I'd like to check the change on AsyncTCP. Bye Renzo |
[STALE_SET] This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs. Thank you for your contributions. |
Dear stale bot. Here's some useless noise to keep you happy. Thanks. |
[STALE_CLR] This issue has been removed from the stale queue. Please ensure activity to keep it openin the future. |
The issue is still here. |
Still here for me too. Tried the |
I ran into this ESP32 bug: espressif/arduino-esp32#1921 Evrything works fine form FireFox, but not at all from chrome or Edge.
having the same problem.. any news? |
For me, it seems this issue finally disappeared with |
@cyberman54 |
@Schrolli91 i was wrong, talking on arduino-esp32 version. Corrected. |
After @cyberman54 comment I gave it a go with v1.0.5 - but I still get the 'Disconnected: RES: 0, ERR: 128' problem. It prompted me to do a bit more debugging - my code is making an HTTP request and its sending a "Connection: close" header, if I take that out (so it defaults to keep-alive) then it works fine and I don't see the 'Disconnected: RES: 0, ERR: 128' problem any more. |
For me too, this issue is gone with V 1.0.5. |
@torntrousers That's in an important note. I checked again my application running on v1.0.5 and can confirm: HTTP headers with "connection close" trigger a "Disconnected" thrown by WiFiClient.cpp, but this does not happen if HTTP header "connection keep-alive" is used. Maybe not a bug, but a feature? |
Never use Connection:close in combination with the current wifi-client. The connection will be gone before data is received. |
I re-test all my examples, and with 1.0.5 core works. |
Finally closed ;-) |
I'm happy to have found this thread. Even though the problem seems fixed by the latest comments, I'm still struggling with the 'Disconnected: RES: 0, ERR: 128' error on a new/updated platform.io installation on linux with ESP32 Pico Kit. What am I missing? Processing pico32 (platform: espressif32; board: pico32; framework: arduino) CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/pico32.html
|
I am also having this problem. |
Arduino Release v2.0.9 - the problem is still there. The only thing that helped me to reduce the impact of this bug it is to run the client-server communication loop in a higher priority task. The nasty "Disconnected: RES: 0, ERR: 128" still pops in the serial monitor from time to time and ESP32 resets connection (can see it in WireShark) but not as often as with 0 priority. |
I noticed that I had this error when a lot of data were sent via WIFI, when I added a 10 ms delay between messages, the error disappeared. This didn't help: |
This is still happening despite the issue opened 6 years ago and closed 2 years ago. I'm using PlatformIO (Core 6.1.15·Home 3.4.4) with Espressif32 v6.7.0. I found the reason in my case and it's a pure PEBKAC. The error started showing when I connected to a server with illegal characters in the URI. I've got to be more careful about those string copies since invisible characters can also be illegal.... |
I was reading this old post looking for incites. Solution was to run the WebSerever.handleClient(); at a higher priority. |
Hardware:
Board: ttgo (and other)
Core Installation/update date: 10/3/2018
IDE name: Arduino IDE 1.8.7
Flash Frequency: 80Mhz
PSRAM enabled: no
Upload Speed: 115200
Computer OS: Windows 10
Description:
I try to install new release of arduino-esp and faced with some picularities in my sketch behavior.
win 10, arduino 1.8.7 , esptool 2.3.1, mkspiffs 0.2.3, xtensa 1.22.0-80-g6c443a-5.2.0.
TTGO board.
Early all work fine - i send HTTP packets from PC to ESP32 and recieve answer about 30 "fps". But after i install new version of IDF (download by arduino "https://dl.espressif.com/dl/package_esp32_index.json") then answer not sends or sends with long timeouts. It seemed that new wificlient.cpp work different in compare with old version.
For example i try to use standard arduino example like SimpleWiFiServer.ino and they also freeze answers...
I print IP adress of esp32 in mozilla firefox (or another program) and after about 3-5 sec i see in debug that HTTP recieved by ESP32 and answered, mozilla some time recive answer, but some time no. Early answer returned very fast.
After i see in debug "client disconnected" then after 100ms i see "new client"! but client.available() == 0 and program spin in while(client.connected()) cycle. Then are timeout event (?) after 5-10sec
[D][WiFiClient.cpp:452] connected(): Disconnected: RES: 0, ERR: 128
and client.connected == 0 - program moove later.
The analysis of debug output shows that client.stop() command not make client.connected() == 0 and in second cycle we catch in infinite while(client.connected()) loop.
What i do wrong? How i can do fast series of HTTP request/answer to esp32? Why in old version (06/2017) all was fine?
Sketch: (leave the backquotes for code formatting)
Debug Messages:
The text was updated successfully, but these errors were encountered: