• Skip to main content
  • Skip to primary sidebar

RNTLab.com

The Ultimate Shortcut to Learn Electronics and Programming with Open Source Hardware and Software

  • Courses
  • Forum
    • Forum
    • Ask Question
  • Shop
  • Account
  • Blog
  • Login

[SOLVED]assert failed: tcp_alloc /IDF/components/lwip/lwip/src/core/tcp.c:1851 (Required to lock TCPIP core functionality!)

Q&A Forum › Category: ESP32 › [SOLVED]assert failed: tcp_alloc /IDF/components/lwip/lwip/src/core/tcp.c:1851 (Required to lock TCPIP core functionality!)
1 Vote Up Vote Down
Sara Santos Staff asked 10 months ago

ISSUE:

In most of our web server and MQTT projects, we use the following libraries (that are currently deprecated):

  • ESPASyncWebServer: https://github.com/me-no-dev/ESPAsyncWebServer
  • AsyncTCP: https://github.com/me-no-dev/asynctcp

Using these libraries will result in the following error and constant rebooting of the ESP32:

assert failed: tcp_alloc /IDF/components/lwip/lwip/src/core/tcp.c:1851 (Required to lock TCPIP core functionality!)

 

SOLUTION:

To fix this issue, you must use the newest fork of those libraries, available on the following links:

  • ESPAsyncWebServer: https://github.com/ESP32Async/ESPAsyncWebServer (at least version 3.6.2)
  • AsyncTCP: https://github.com/ESP32Async/AsyncTCP (at least version 3.3.2)

 

Follow these instructions to solve the issue:

  • Go to the Arduino Libraries Manager: Sketch > Include Library > Manage Libraries
  • UNINSTALL any previous versions of the ESPAsyncWebServer and AsyncTCP libraries
  • Now, you can install the latest version of the new fork.  Follow the next instructions:

To guarantee that you’re using the latest version of the ESPAsyncWebServer and AsyncTCP libraries, please install them via ZIP folder (don’t use the Library Manager that will currently install an older version with issues).

Click the following links to download the library files.

  • Click here to download the ESPAsyncWebServer
  • Click here to download the Async TCP library.

In your Arduino IDE, go to Sketch > Include Library > Add .zip Library and select the libraries you’ve just downloaded.

 

Compile your code again. This will work with the latest version of the ESP32 core.

 

 

 

6 Answers
0 Vote Up Vote Down
Brian answered 3 weeks ago

I have a MQTT project in VSCode / Platformio that at one time ran great on my esp32-s3 and RPI-5.  I attempted to upgrade the code but once downloaded I get the following error
”  assert failed: tcp_alloc /IDF/components/lwip/lwip/src/core/tcp.c:1851 (Required to lock TCPIP core functionality!)”
Here is a list of included files:

#include <Arduino.h>
#include <OneWire.h>
#include “DallasTemperature.h”
#include <WiFi.h>
#include <AsyncMqttClient.h>
#include <string>

extern “C”
{
#include “freertos/FreeRTOS.h”  //
#include “freertos/timers.h”
}

 
and libraries:

lib_deps =
    marvinroger/AsyncMqttClient@^0.9.0
    paulstoffregen/OneWire@^2.3.8
    milesburton/DallasTemperature@^4.0.5
 

I’m not using the ESPAsyncWebServer or AsyncTCP libraries.  Please help me figure out how to clear this error.
 

 
 

0 Vote Up Vote Down
Sara Santos Staff answered 3 weeks ago

Hi.
When you say you atempted to upgrade the code, what do you mean exactly?
Can you share your complete plaformio.ini file?
 
Regards,
Sara

0 Vote Up Vote Down
Brian answered 3 weeks ago

There were some features of my original working program that I wanted to improve.  When I made the changes I started to receive the error and reboot issue.  Even when I reflashed the esp with the once working version the problem remains.  As the program was written several years back, there have been changes to the api version and I since changed to pioarduino.  Here is a copy of the full platformio.ini file minus the comments:

[env:esp32doit-devkit-v1]
platform = espressif32
board = esp32-s3-devkitc-1
framework = arduino
lib_deps =
    marvinroger/AsyncMqttClient@^0.9.0
    paulstoffregen/OneWire@^2.3.8
    milesburton/DallasTemperature@^4.0.5

0 Vote Up Vote Down
Brian answered 3 weeks ago

Thanks for looking at this.  I asked copilot to look at the code and his suggestions fixed the issue.  Here is the output summary:
 
Patch applied — changes summary:
Added lwIP header include: #include “lwip/tcpip.h”
Added function connectOnTcpipThread(void*) that calls mqttClient.connect().
Replaced direct mqttClient.connect() call in the main loop with tcpip_callback(connectOnTcpipThread, NULL).
Why this should fix the assert
tcpip_callback schedules a function to run on the lwIP TCPIP thread while holding the required TCPIP core lock. Any allocations or TCP operations performed there won’t trigger the tcp_alloc assert.
This is safer than calling connect() from event/timer contexts or even the main loop if the library expects to run on the TCPIP thread.
 

0 Vote Up Vote Down
Sara Santos Staff answered 2 weeks ago

Hi.
Thanks for sharing that.
We would have suggested adding the following line to your platformio.ini file:

platform = https://github.com/pioarduino/platform-espressif32/releases/download/stable/platform-espressif32.zip

 
Instead of:

platform = espressif32

 
But, if it is working as expected now, it’s better to proceed at it is.
 
Regards,
Sara
 

0 Vote Up Vote Down
Brian answered 2 weeks ago

Thanks Much

Primary Sidebar

Login to Ask or Answer Questions

This Forum is private and it’s only available for members enrolled in our Courses.

Login »

Latest Course Updates

  • [eBook Updated] Smart Home with Raspberry Pi, ESP32, and ESP8266 V1.6 September 9, 2025
  • [eBook Updated] Learn LVGL: Build GUIs for ESP32 Projects – Version 1.5 July 7, 2025

You must be logged in to view this content.

Contact Support - Refunds - Privacy - Terms - MakerAdvisor.com - Member Login

Copyright © 2013-2025 · RandomNerdTutorials.com · All Rights Reserved

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.