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

XAsyncTCPServerException: OnClientAccepted event: timeoutSec is incorrect to set timeout expire #74

Open meghadeep-com opened 3 years ago

meghadeep-com commented 3 years ago

There's a weird issue with timeoutSec that's happening on every new connection.

This is my code:

from MicroWebSrv2 import *
mws2 = MicroWebSrv2()
mws2.StartManaged(parllProcCount=1, procStackSize=4)

@WebRoute(GET, '/data-test')
def dataSend(microWebSrv2, request):
    request.Response.ReturnOk(None)

@WebRoute(GET, '/data')
def dataSend(microWebSrv2, request):
    request.Response.ReturnOk(ujson.dumps(payload_maker()))
    #request.Response.ReturnOkJSON(payload_maker())

This is the error I am getting: image

meghadeep-com commented 3 years ago

I tried this dirty thing:

def _setExpireTimeout(self, timeoutSec) :
    try :
        if timeoutSec and timeoutSec > 0 :
            self._expireTimeSec = perf_counter() + timeoutSec
    except :
        self._expireTimeSec = perf_counter() + 3
        # raise XAsyncSocketException('"timeoutSec" is incorrect to set expire timeout.')

But it raises yet another image

This happens any time I try to send a GET request to one of the routes. I have changed the regex routing rule already to accommodate for ESP32.

xlla commented 2 years ago

save problem here on esp32 board,

>>> mws2.StartManaged(procStackSize=4*1024)
MWS2-INFO> Server listening on 0.0.0.0:80.
MWS2-INFO> Starts the managed pool to wait for I/O events.
>>> Unhandled exception in thread started by 
Traceback (most recent call last):
  File "MicroWebSrv2/libs/XAsyncSockets.py", line 131, in _processWaitEvents
  File "MicroWebSrv2/libs/XAsyncSockets.py", line 425, in OnReadyForReading
XAsyncTCPServerException: Error when handling the "OnClientAccepted" event : "timeoutSec" is incorrect to set expire timeout.