Sending data over UDP socket crashes my system

simonjo
Posts: 32
Joined: Wed Sep 30, 2020 9:16 am

Sending data over UDP socket crashes my system

Postby simonjo » Tue Sep 09, 2025 7:53 pm

Hi,

My application was created with ESP-IDF v4.x and the syslog logging worked just fine.

In jan 2025 I moved to ESP-IDF 5.4.1 which required me to adjust source code to match the new framework, but after that it functions as expected, except for the syslog logging althoug I did not change the logging module.

My application has a main task as created by the ESP-IDF, and 2 additional tasks (one on each core) that run a worker thread to support sub-tasks. In these subtasks we have 2 HTTP servers, 1 MQTT client and a TCP protocol driver. These all use non-blocking TCP sockets.

The logging module logs to console, a weblog and syslog over UDP socket.

When I enable syslogging I notice that the tasks die and the complete application is not responsive. Via a recovery method I can disable the syslogging and then the system works fine again.

What I notice is that sending data over the UDP socket (writeLine:sendto) returns ENOMEM after a few writes, and then we don't talk about big data, see example below.

From the moment writeLine:sendto returns err=12 (ENOMEM) the application starts dying as if memory is being eaten.

I compared sdkconfig as used in ESP-IDF v4.x and 5.4.1 but I don't see a problem

Anybody an idea?
Thx, Jo

>>>
2025-09-09,20:57:51,D,SNTP,!Initialising...
writeLine:sendto(46)
2025-09-09,20:57:51,I,HTPS,!Started
writeLine:sendto(62)
2025-09-09,20:57:51,I,MQTC,>Connecting to broker...
writeLine:sendto(60)
2025-09-09,20:57:51,I,RPCS,!XMLRPC server started
writeLine:sendto(64):err=12
2025-09-09,20:57:51,I,MQTC,<Connected to 192.168.0.10
writeLine:sendto(80):err=12
<<<

nopnop2002
Posts: 362
Joined: Thu Oct 03, 2019 10:52 pm
Contact:

Re: Sending data over UDP socket crashes my system

Postby nopnop2002 » Thu Sep 11, 2025 2:25 am

Anybody an idea?
1 Create a new UDP client task.
https://github.com/nopnop2002/esp-idf-n ... p_client.c

2 Replace sendto() with xRingbufferSend() or xMessageBufferSend().

You can use this component.
https://github.com/nopnop2002/esp-idf-n ... /tree/main

simonjo
Posts: 32
Joined: Wed Sep 30, 2020 9:16 am

Re: Sending data over UDP socket crashes my system

Postby simonjo » Fri Sep 12, 2025 6:11 pm

Thank you for the response.

However, I find the proposed workarounds a bit over the top.

Certainly given the fact that this worked just fine with esp-idf 4.x on one hand, on the other hand, we are not talking about big data that we are sending.

After sending 160 bytes to the UDP socket things went wrong... huh !? This is a fundamental issue in the esp-idf in my view.

Is someone from espressif listening on this topic ?


regards, Jo

eriksl
Posts: 239
Joined: Thu Dec 14, 2023 3:23 pm
Location: Netherlands

Re: Sending data over UDP socket crashes my system

Postby eriksl » Sun Aug 02, 2026 10:41 am

I am doing it all of the time, with datagrams up to 32k. So IDF isn't at fault here IMHO.

Who is online

Users browsing this forum: No registered users and 1 guest