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
662 stars 97 forks source link

Not compatible with Micropython 1.21.0? #99

Open kenjican opened 11 months ago

kenjican commented 11 months ago
  MicroWebSrv2  2.0.6 have been working well with MicroPython V.1.20.0 and versions before.

  But , at version Micropython 1.21.0 , when connecting it shows  server closed as below:

MWS2-INFO> Server listening on 0.0.0.0:80. MWS2-INFO> Starts the managed pool to wait for I/O events. MWS2-INFO> Server 0.0.0.0:80 closed. MWS2-INFO> Stops the managed pool.

Anyone bump into this problem also?

jczic commented 9 months ago

Is this still the case after the recent commits?

kenjican commented 8 months ago

I tried recent commits and Micropython 1.22.1 。 Sever not closed but still can not open the html page. as below:

   - Python pkg MicroWebSrv2 -
   -      version 2.0.6      -
   -     by JC`zic & HC2     -
   ---------------------------
ekondayan commented 8 months ago

Same here. Breaking commit is 2f1e982cad28be776d124bfeaae34e01f82fe177. The server starts and hangs on MWS2-INFO> Starts the managed pool to wait for I/O events. When I try to open a webpage the curl/browser hangs and also the webserver hangs. If I try to stop it with CTRL+C it doesn't responds for about 30 seconds before the key presses get registered and the server stops

Micropython versions tested: 1.22.2 and all in between the latest master ESP-IDF versions tested: latest 5.1 and 5.2

jczic commented 8 months ago

Hello and thank you for your feedback. can you try to start the server with : StartManaged(0) or StartManaged(2) ?

ekondayan commented 8 months ago

With StartManaged(2) the server hangs and even CTRL+C does not work With StartManaged(0) I am able to halt the server with CTRL+C. Once I was able to download the index.html, but even then the server responded about 20 seconds later and then hanged again.

Here is the output when I stop it with CTRL+C

MWS2-INFO> Server listening on 0.0.0.0:80. MWS2-INFO> Starts the managed pool to wait for I/O events.

hit 5-10 times CTRL+C

MWS2-INFO> Server 0.0.0.0:80 closed. MWS2-INFO> Stops the managed pool. Traceback (most recent call last): ... File "MicroWebSrv2/microWebSrv2.py", line 222, in StartManaged File "MicroWebSrv2/microWebSrv2.py", line 238, in Stop File "MicroWebSrv2/libs/XAsyncSockets.py", line 270, in StopWaitEvents KeyboardInterrupt: MicroPython v1.23.0-preview.233.gafeba9050 on 2024-03-15;

I'd like to help you debug it, but I do not know where to start.

recklessop commented 8 months ago

Same problem here. Server starts but cannot get to any routes. (1.22.0 here too)

update: I rolled back to 1.20 Micropython and 2.0.6 of MicroWebSrv2 and I am now able to get responses from the webserver.

Not that I am running this on an ESP32-Wroom in embedded mode. So I can confirm what @ekondayan was saying about the commit breaking things.

ekondayan commented 7 months ago

I've been testing the latest commit (4a7f59938a83802d08d154774befea73a644b99e) - it is still not working reliably but this time with a twist.

This time I am able to get the index.html a few times in a row(using curl) but then the server stops serving again. I wasn't able to get a complete webpage using a regular browser - index.html, CSS and two JS files( 420KB in total ). The difference now is that I can get at least one index.html served but the server blocks for the rest of the page assets. I also noted that in this blocked state, the server is handling the websocket messages correctly.

If you give me a modified XAsyncSockets.py, stuffed with debug print statements, I can send you the output.

jczic commented 7 months ago

Hmm, thank you @ekondayan. Strange indeed. And how do you start the server at the beginning? I use it on big projects with TLS/SSL (on Azure cloud) and it still works. I launch it with 5 parallel processes. Do you use it in embedded mode or on a normal server (linux or other)?

ekondayan commented 7 months ago
    mws2 = MicroWebSrv2()
    mws2.RootPath = '/www'
    mws2.SetEmbeddedConfig()  # For embedded MicroPython, use a very light configuration,
    mws2.DisableSSL()
    mws2.NotFoundURL = '/'  # All pages not found will be redirected to the home '/',
    mws2.StartManaged()

My environment is:

ekondayan commented 7 months ago

I've tested the latest commit and it still does not work on esp32 with micropython

WolleKette commented 3 months ago

Are there any updates regarding compatibility in the meantime? i'm currently using MicroPython 1.24 on an ESP32-S3-DevKitC1U-N8R8 and it doesn't work here.