jczic / MicroWebSrv2

The last Micro Web Server for IoTs (MicroPython) or large servers (CPython), that supports WebSockets, routes, template engine and with really optimized architecture (mem allocations, async I/Os). Ready for ESP32, STM32 on Pyboard, Pycom's chipsets (WiPy, LoPy, ...). Robust, efficient and documented!
https://github.com/jczic/MicroWebSrv2
MIT License
659 stars 97 forks source link

Slow Initial Open Connection of Websocket #60

Open ehtnevets opened 3 years ago

ehtnevets commented 3 years ago

My unsophisticated measurement (1-1000, 2-1000, ...), I think, is quite accurate since it takes around 7s-10s to establish websocket connection. I start counting when I press enter and stop when I see "Example WebSocket accepted:" on the console.

I'm running micropython compiled with esp-idf 4.0 on ESP32 variant (Heltec Wifi Kit 32). Only micropython, WLAN, and microWebSrv2 are running. No other module is loaded. Setting freq to 240MHz seems to help a bit but still in the 7s-10s response time.

The js scripts loaded can be found on https://github.com/hallard/WebSocketToSerial. It takes about 20s-30s to load the scripts. With the C++ webserver from the git project, the script loading is blazing fast on and websocket connection established instantly.

HTTP Request response is also about 7s-10s from the time I hit enter on the web browser url field until I see "MWS2-DEBUG>...GET.." log print on console for request on any html file. Not just the terminal javascript.

I do expect that running micropython will be quite a bit slower but do not expect this much slower.

What should I look on the setup to speed this thing up to a more reasonable speed.

Thank you.

volodimirk31 commented 1 year ago

Hey! I have the same issue... One of the iterations of project takes 14-15 seconds to establish a WS connection. Then it works totally fine Have You been able to find a "cure"?