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

ESP32 BLE/WiFi throws an error [E][WiFiClient.cpp:395] write(): fail on fd 54, errno: 11, "No more processes" - still not resolved #6129

Closed
1 task done
sudheeshsmadhav opened this issue Jan 12, 2022 · 80 comments
Assignees
Labels
Area: WiFi Issue related to WiFi Status: Pending Merge Pull Request is ready to be merged

Comments

@sudheeshsmadhav
Copy link

Board

ESP32 devkit v4

Device Description

I am using ESP32 devkit v4

Hardware Configuration

no GPIO connections, ESP32 scans the BLE tags and sends their id and rssi values over mqtt

Version

latest master

IDE Name

Platform IO also uses arduino IDE 1.8.57.0

Operating System

Windows10

Flash frequency

80MHz

PSRAM enabled

no

Upload speed

115200

Description

ESP32 scans the available BLE tags and publishing the collected information over mqtt (Raspberry Pi 4 B is the broker). It was working fine in the last month.
now it started to print error in the console something like [E][WiFiClient.cpp:395] write(): fail on fd 54, errno: 11, "No more processes" and after some time it restarts. BLE scan runs in a freeRTOS task. MQTT publishing is in loop().

it works fine for around 5min(time interval is random) then fails and reboot as the log mentioned.

[E][WiFiClient.cpp:395] write(): fail on fd 54, errno: 11, "No more processes"
[E][WiFiClient.cpp:395] write(): fail on fd 54, errno: 113, "Software caused connection abort"

Sketch

will provide if requested.

Debug Message

[E][WiFiClient.cpp:395] write(): fail on fd 54, errno: 11, "No more processes"
[E][WiFiClient.cpp:395] write(): fail on fd 54, errno: 11, "No more processes"
[E][WiFiClient.cpp:395] write(): fail on fd 54, errno: 11, "No more processes"
[E][WiFiClient.cpp:395] write(): fail on fd 54, errno: 11, "No more processes"
[E][WiFiClient.cpp:395] write(): fail on fd 54, errno: 11, "No more processes"
[E][WiFiClient.cpp:395] write(): fail on fd 54, errno: 11, "No more processes"
[E][WiFiClient.cpp:395] write(): fail on fd 54, errno: 11, "No more processes"
[E][WiFiClient.cpp:395] write(): fail on fd 54, errno: 11, "No more processes"
[E][WiFiClient.cpp:395] write(): fail on fd 54, errno: 11, "No more processes"
[E][WiFiClient.cpp:395] write(): fail on fd 54, errno: 113, "Software caused connection abort"
PUB Result: 0
number of uploads: 153

ets Jun  8 2016 00:22:57

rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0018,len:4
load:0x3fff001c,len:1044
load:0x40078000,len:10124
load:0x40080400,len:5828
entry 0x400806a8

Other Steps to Reproduce

No response

I have checked existing issues, online documentation and the Troubleshooting Guide

  • I confirm I have checked existing issues, online documentation and Troubleshooting guide.
@sudheeshsmadhav sudheeshsmadhav added the Status: Awaiting triage Issue is waiting for triage label Jan 12, 2022
@MomePP
Copy link

MomePP commented Jan 16, 2022

I also got this error but in my case, it's a Wi-Fi AP as webserver by using WiFiManager. After started webserver, ESP writing response to client. This error showing up then crash.

This only happended with latest release(2.0.2). Downgrade to 2.0.1, It works fine.

@BeaverUI
Copy link

I have exactly the same issue with my code. I use MQTT, BLE, and WiFi together on an ESP32. It runs for a while, and then resets at a quasi-random time.

@MomePP: I didn't get your comment, I believe the WiFiClient is in the board definitions file, and no version 2.0.2 there. Or am I missing something?

@sudheeshsmadhav
Copy link
Author

I didn't use the WiFiManager. h

#include <WiFi.h>
#include <PubSubClient.h>
#include <ArduinoJson.h>
#include <ESP32Time.h>
#include <WiFiUdp.h>
#include <BLEDevice.h>
#include <BLEUtils.h>
#include <BLEScan.h>
#include <BLEAdvertisedDevice.h>

I use only these files in my code

@BeaverUI
Copy link

I have these:

#include <WiFi.h>
#include "BLEDevice.h"
#include <ESPmDNS.h>
#include <ArduinoOTA.h>
#include <MQTT.h>
#include <WiFiClient.h>

Different MQTT library, by the way.

@MomePP
Copy link

MomePP commented Jan 22, 2022

@BeaverUI

Sorry for the confusion. What I mean is version of ESP32 Arduino Core that i used and WiFiClient is part of definition file in WiFi library.

In my case i used WiFiManager library, which is based from WiFi library. So i got the same issue with WiFiClient.
However, I didn't use BLE.

@BeaverUI
Copy link

BeaverUI commented Jan 22, 2022

Thanks, I changed to 2.0.1 now, let's see what happens. It usually takes less than 24 hours before it throws the error.

@BeaverUI
Copy link

Oops, it did it again. Changing the Arduino Core made no difference. What I notice is that some processes seem to struggle:

  • My mqtt broker sometimes gives a timeout on the connection to the ESP
  • WiFi on the ESP sometimes reconnects
  • BLE on the ESP sometimes throws an error
  • The available heap decreases continuously, but I can't find any leaks in my code. When doing scans only, without connecting, there is no leak.
  • After a while the ESP reboots or freezes, which is at a random moment but always seem to align with the moment that BLE is active.

@sudheeshsmadhav
Copy link
Author

Hi, changed some library files and their versions. Still the issue available. Anybody identified any possible solutions? I reinstalled the Arduino ide, tried different versions of library files. No use... It is still makes me mad.

@sudheeshsmadhav sudheeshsmadhav changed the title ESP32 BLE/WiFi throws an error [E][WiFiClient.cpp:395] write(): fail on fd 54, errno: 11, "No more processes" ESP32 BLE/WiFi throws an error [E][WiFiClient.cpp:395] write(): fail on fd 54, errno: 11, "No more processes" - still not resolved Jan 31, 2022
@sudheeshsmadhav
Copy link
Author

Not a permanent solution but some how I am able to handle it. I am repeatedly sending data from esp to server, So this problem made some gap in the communication. As the error printed - [E][WiFiClient.cpp:395] write(): fail on fd 54, errno: 11, "No more processes" , I am able to point out the error code in the wificlient.cpp file. Upon printing the log, I made the ESP to restart. So ESP will get in to the active loop within few seconds rather than printing the error log in console for more than 10 seconds. But looking for a permanent solution.

@sudheeshsmadhav
Copy link
Author

any solution for this. ?

@VojtechBartoska
Copy link
Collaborator

Hello all contributors, can you please retest this on v2.0.3-rc1?

@VojtechBartoska VojtechBartoska added Area: BT&Wifi BT & Wifi related issues Resolution: Awaiting response Waiting for response of author and removed Status: Awaiting triage Issue is waiting for triage labels Apr 11, 2022
@VojtechBartoska
Copy link
Collaborator

I'm closing the issue as expired due to no answer.

If needed, please reopen it.

Thanks for understanding.

@VojtechBartoska VojtechBartoska added Resolution: Expired More info wasn't provided and removed Resolution: Awaiting response Waiting for response of author labels May 4, 2022
@maxdd
Copy link

maxdd commented May 27, 2022

I do have a similar issue with chunked data (nothing related with BLE which i dont know what it is mentioned in this issue)

[  4906][D][HTTPClient.cpp:598] sendRequest(): request type: 'GET' redirCount: 0

[  4957][D][HTTPClient.cpp:1156] connect():  connected to www.meteoproject.it:80
[  5047][D][HTTPClient.cpp:1307] handleHeaderResponse(): code: 200
[  5047][D][HTTPClient.cpp:1314] handleHeaderResponse(): Transfer-Encoding: chunked
[  5049][D][HTTPClient.cpp:628] sendRequest(): sendRequest code=200

[  5056][D][HTTPClient.cpp:922] writeToStream():  read chunk len: 16780
[  5159][D][HTTPClient.cpp:1446] writeToStreamDataBlock(): connection closed or file end (written: 16780).
[  5160][D][HTTPClient.cpp:922] writeToStream():  read chunk len: 0
[  5164][D][HTTPClient.cpp:388] disconnect(): still data in buffer (2), clean up.

[  5171][E][WiFiClient.cpp:516] flush(): fail on fd 50, errno: 11, "No more processes"
.[  5181][D][HTTPClient.cpp:393] disconnect(): tcp keep open for reuse

Seems like after the trailing sequence some data is still present in the buffer

char b[2] = {0,0};
_client->readBytes((uint8_t*)b, 2);
Serial.printf("char 1 - %x - ", b[0]);
Serial.printf("char 2 - %x -\n", b[1]);
[  3686][D][HTTPClient.cpp:922] writeToStream():  read chunk len: 16783
[  3773][D][HTTPClient.cpp:1450] writeToStreamDataBlock(): connection closed or file end (written: 16783).
char 1 - 30 - char 2 - d -
[  3784][W][HTTPClient.cpp:1473] returnError(): error(-11): read Timeout
[  3784][D][HTTPClient.cpp:1475] returnError(): tcp stop

Is it a server-side issue?

@ln-12
Copy link

ln-12 commented Jun 13, 2022

Hey @VojtechBartoska, I am using 2.0.3 (stable) and experiencing the same issue.

@VojtechBartoska
Copy link
Collaborator

I'm reopening the issue and we will take a look on it.

@VojtechBartoska VojtechBartoska added Status: Needs investigation We need to do some research before taking next steps on this issue and removed Resolution: Expired More info wasn't provided labels Jun 14, 2022
@sudheeshsmadhav
Copy link
Author

sudheeshsmadhav commented Jun 15, 2022

The issue is still existing and I am restarting the esp to overcome this quickly. Looking for a permanent solution.

Using able scan, collection the Bluetooth tag id and their rssi value, publishing it using mqtt.
A ble scan runs in freertos task.

@sudheeshsmadhav
Copy link
Author

The issue still existing. I am just restarting the esp32 upon getting this error currently.
Looking for a permanent solution. Loosing some data during the esp restart.

Scanning the ble beacons in free rtos task, publishing to server using mqtt. Using pubsubclient library.

Esp restarts/causing this problem randomly. Say after 5min..

@PilnyTomas PilnyTomas added Resolution: More info needed More info must be provided in this issue Resolution: Awaiting response Waiting for response of author Status: Community help needed Issue need help from any member from the Community. Area: WiFi Issue related to WiFi labels Jul 3, 2023
@OptifySudarshanPatil
Copy link

OptifySudarshanPatil commented Jul 28, 2023

i'm getting same prompt with this code.
Good news data is received on server with "200" code

#include "Arduino.h"
#include <WiFi.h>
#include <HTTPClient.h>

const char* ssid = "device";
const char* password = "1223334444";

//Your Domain name with URL path or IP address with path
const char* serverName = "http://sample.com/api/";

// the following variables are unsigned longs because the time, measured in
// milliseconds, will quickly become a bigger number than can be stored in an int.
unsigned long lastTime = 0;
// Timer set to 10 minutes (600000)
//unsigned long timerDelay = 600000;
// Set timer to 5 seconds (5000)
unsigned long timerDelay = 5000;

void setup() {
  Serial.begin(115200);

  WiFi.begin(ssid, password);
  Serial.println("Connecting");
  while(WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  Serial.println("");
  Serial.print("Connected to WiFi network with IP Address: ");
  Serial.println(WiFi.localIP());
 
  Serial.println("Timer set to 5 seconds (timerDelay variable), it will take 5 seconds before publishing the first reading.");
}

void loop() {
  //Send an HTTP POST request every 10 minutes
  if ((millis() - lastTime) > timerDelay) {
    //Check WiFi connection status
    if(WiFi.status()== WL_CONNECTED){
      WiFiClient client;
      HTTPClient http;
      // Your Domain name with URL path or IP address with path
      http.begin(client, serverName);
      // If you need Node-RED/server authentication, insert user and password below
      //http.setAuthorization("REPLACE_WITH_SERVER_USERNAME", "REPLACE_WITH_SERVER_PASSWORD");
      // Specify content-type header
      http.addHeader("Content-Type", "application/x-www-form-urlencoded");
      // // Data to send with HTTP POST
      // String httpRequestData = "api_key=tPmAT5Ab3j7F9&sensor=BME280&value1=24.25&value2=49.54&value3=1005.14";           
      // // Send HTTP POST request
      // int httpResponseCode = http.POST(httpRequestData);
      // If you need an HTTP request with a content type: application/json, use the following:
      http.addHeader("Content-Type", "application/json");
      int httpResponseCode = http.POST("{\"Serial_no\":\"12345\",\"id\":\"2\",\"V1\":\"24.25\",\"V2\":\"49.54\",\"value3\":\"1005.14\"}");
      // If you need an HTTP request with a content type: text/plain
      //http.addHeader("Content-Type", "text/plain");
      //int httpResponseCode = http.POST("Hello, World!");
      Serial.print("HTTP Response code: ");
      Serial.println(httpResponseCode);
      // Free resources
      http.end();
    }
    else {
      Serial.println("WiFi Disconnected");
    }
    lastTime = millis();
  }
}

Terminal data
image

@VojtechBartoska VojtechBartoska self-assigned this Aug 15, 2023
@VojtechBartoska VojtechBartoska removed Resolution: More info needed More info must be provided in this issue Resolution: Unable to reproduce With given information issue is unable to reproduce Resolution: Awaiting response Waiting for response of author labels Aug 15, 2023
@PilnyTomas
Copy link
Contributor

Guys, please test PR #8541 and let me know if it works for you. I just hope it doesn't create a new issue :D

@OptifySudarshanPatil
Copy link

Hello @PilnyTomas
Your changes are working as expected. Thanks!
This issue is resolved for me.
Hope this changes will show up into platformio esp32 core.
✌️
image

@VojtechBartoska VojtechBartoska added Status: In Progress Issue is in progress and removed Status: Needs investigation We need to do some research before taking next steps on this issue labels Aug 21, 2023
@PilnyTomas PilnyTomas added Status: Pending Merge Pull Request is ready to be merged and removed Area: BT&Wifi BT & Wifi related issues Status: In Progress Issue is in progress Status: Community help needed Issue need help from any member from the Community. labels Aug 22, 2023
@CelliesProjects
Copy link
Contributor

CelliesProjects commented Aug 29, 2023

@PilnyTomas Works like a charm. Thanks for the effort!

@Oekologisiert
Copy link

I think i found a workraround until all packages are updated with espressif32@6.3.1 in platformio.ini
The problem occures in my case only with espressif32@6.4

@tablatronix
Copy link
Contributor

Same issue, also wifi drops out and fails to reconnect, and debugging of course also stopped logging sigh.
Will isolate version

@VojtechBartoska
Copy link
Collaborator

will be fully addressed again in #8699

@arturstopa
Copy link

arturstopa commented Oct 19, 2023

I get the same issuem I'm using WebSockets @ 2.4.1 and WiFi @ 2.0.0
PLATFORM: Espressif 32 (6.4.0) > Espressif ESP32 Dev Module

I'm pretty sure that webSocket.begin() is triggering the error [WiFiClient.cpp:517] flush(): fail on fd 48, errno: 11, "No more processes". CI of WebSockets library is failing, but the error itself is in the WiFi library, so I believe it's worth checking.

@sudheeshsmadhav
Copy link
Author

sudheeshsmadhav commented Feb 23, 2024

Hi, Is this issue is fully addressed? and in which version? I am still getting the same error in espressif32@4.3.0 - Working with platformio. Also tried this with the following
; platformio/framework-arduinoespressif32@^3.20014.231204
; platform = espressif32

but no luck,
This error hits after 20+ minutes of run.
After sometime ESP32 crashing and restarting.

Please let me know if the fix is released / available in any one branch..
My hardware devices - more than 500 units affected with this.

@VojtechBartoska
@PilnyTomas

@VojtechBartoska
Copy link
Collaborator

version 2.0.14 of Arduino core

@bbhxwl
Copy link

bbhxwl commented Jun 4, 2024

I also have the same problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: WiFi Issue related to WiFi Status: Pending Merge Pull Request is ready to be merged
Projects
Development

No branches or pull requests