Request times vary by 100ms on server, client send them every 256 ms

noweare
Posts: 101
Joined: Tue Jul 02, 2019 11:35 am

Request times vary by 100ms on server, client send them every 256 ms

Postby noweare » Wed Jul 01, 2026 3:18 pm

Using an esp32 v5.5 esp-idf audio server to web client

working on an audio project where i am getting request every 256 msecs from the client for data.
i am using an i2 interrupt driven task to read samples from the i2s dma buffers so there no blocking.
The interrupt happens every 256 msecs. I am logging the interval between when i
recieve the request from the client in the handler and it alternates between 205 msecs and 307 msecs. The
interrupt and storing the data is done within the 10 msec resolution of the esp_logi statement.
The sending of the data is also within the 10 ms window of the esp_logi.
I am trying to understand why the variance in the server responding to
the request as everything else in the code is periodic and fast.

It seems like something is taking 50 msecs somewhere before it can respond to the
request so thats why i get the 307 msec delay instead of 256 msecs.

The average of the two is close to the 256 ms i would expect.

I am thinking it is something behind the scenes ie task scheduler
or a network thing.

Maybe someone has experienced this and point me in a direction.

MicroController
Posts: 2693
Joined: Mon Oct 17, 2022 7:38 pm
Location: Europe, Germany

Re: Request times vary by 100ms on server, client send them every 256 ms

Postby MicroController » Fri Jul 03, 2026 10:46 am

You'll have to clarify some more.
I am logging the interval between when i recieve the request from the client in the handler and it alternates ...
Interval between what?
I am trying to understand why the variance in the server responding to the request
Impossible to tell without knowing anything about your code.

Generally, notice that logging isn't "free". Log output tends to be slow, e.g. about 11KB/s (~90ms/KB) at 115200bps, and logging calls may block until their, and all preceding, log data has made it out of the chip, or at least into the size-limited FIFO buffer.

noweare
Posts: 101
Joined: Tue Jul 02, 2019 11:35 am

Re: Request times vary by 100ms on server, client send them every 256 ms

Postby noweare » Sat Jul 04, 2026 12:14 am

The interval between requests from the client as seen in the server handler. The client request (at the client) are 256 msecs apart all the time. But the server sees the request (in the handler on the server) at an alternating 205 and 309 msecs. So i am expecting the server to log the request fairly uniformly time wise around the same time (256 ms) not a 50 msec difference. This is an audio app using i2s ( baby monitor so its voice audio packets at 8kHz single channel) but i am using .on_rcv callback so that I am not blocking waiting for buffers to fill up.

I am figuring out how to use wireShark to see if my network is doing anything strange to cause this. I did not post the code since it is so long. If I cant figure out whats going on in a few days I will post it or link to github.

noweare
Posts: 101
Joined: Tue Jul 02, 2019 11:35 am

Re: Request times vary by 100ms on server, client send them every 256 ms

Postby noweare » Sun Jul 05, 2026 3:38 pm

So the latency is coming from my home network and not the esp32 code. I figured that out by using the esp32 in ap mode and then pinged it from my pc. The numbers were much better. That isolates the esp32 stack from my home network.

Sprite
Espressif staff
Espressif staff
Posts: 10636
Joined: Thu Nov 26, 2015 4:08 am

Re: Request times vary by 100ms on server, client send them every 256 ms

Postby Sprite » Mon Jul 06, 2026 12:25 am

Could also be WiFi power saving; that's not active in AP mode, but is in STA mode. I'd try disabling that.

noweare
Posts: 101
Joined: Tue Jul 02, 2019 11:35 am

Re: Request times vary by 100ms on server, client send them every 256 ms

Postby noweare » Fri Jul 24, 2026 3:16 pm

I had the power savings disabled in AP mode which was not needed and but not in station mode where I needed it. That fixed a lot of the delays. I ran into another problem though. When the baby monitor was running, if I stopped and started a youtube video it would introduce a delay (only when starting the video). Youtube and baby monitor was on the same machine. I guess my internet service is not that great, lol.

Who is online

Users browsing this forum: Amazon [Bot], Bytespider, Semrush [Bot] and 0 guests