Why are WebSockets so painfully slow?

username
Posts: 507
Joined: Thu May 03, 2018 1:18 pm

Re: Why are WebSockets so painfully slow?

Postby username » Fri Jul 07, 2023 5:50 am

Im shocked that its taking ~7.6min for OTA.
I use OTA all the time, In fact its far faster than using USB even when set to the highest speed.
I use the ESP32-S3 8MB version.
For me, even when sending a 3.5M firmware OTA update only takes like 6-8 seconds, and I am using web sockets as well.

bidrohini
Posts: 202
Joined: Thu Oct 27, 2022 12:55 pm

Re: Why are WebSockets so painfully slow?

Postby bidrohini » Fri Jul 07, 2023 8:59 am

The WebSocket behavior can vary based on the specific implementation and configuration settings. Different WebSocket libraries or frameworks may have their own optimizations, buffer sizes, or timeout settings that affect the overall performance. It's worth exploring the WebSocket implementation you are using and its configuration options to see if any adjustments can be made to mitigate the delays.

To optimize the OTA update process over WebSockets, you can consider the following approaches:

Instead of using small packet sizes like 32kB, try using larger chunks of data. Experiment with different packet sizes to find the optimal balance between reduced overhead and reliable transmission.
Divide the firmware file into smaller chunks and send them sequentially over the WebSocket connection. This way, you can transmit larger portions of data without hitting timeout limitations.

Implement a progress reporting mechanism to inform the client about the status of the OTA update. This can help manage expectations and provide feedback to the user during the transmission process.

Implement appropriate timeouts and retry mechanisms on the client-side to handle potential failures or interruptions during the OTA update. This can help ensure robustness and recovery in case of network issues.

Analyze and optimize your network environment to reduce latency and improve overall communication performance. This can involve examining network configurations, firewall settings, or considering alternative network protocols if applicable.

To get all the basic info about ESP32 web socket servers in one place, you can see this article: https://www.theengineeringprojects.com/ ... erver.html

Who is online

Users browsing this forum: Majestic-12 [Bot] and 408 guests