Restarting webserver after soft reboot
See original GitHub issueDear Jean-Christophe,
we are very happy about the new release of your fine webserver library. For now, it looks like it works very stable on one of our FiPy devices sitting on our workbench.
We are in the process of porting the Terkin Datalogger [1] to MicroWebSrv2
and experienced this issue after exiting the program using CTRL+C
and invoking a soft reboot using CTRL+D
.
It looks like the listener does not go away and so, MicroWebSrv2
can do nothing about its IsRunning
method suitable for detecting this. The Webserver isn’t actually running but it looks like XAsyncSocket
does not give up it’s listening socket on program termination, so it is obvious it can’t bind again to the same port after coming back from the soft reboot.
It currently looks like that for us:
PYB: soft reboot
[...]
15.6195 [terkin.network.core ] INFO : Setting up HTTP API
15.6389 [terkin.api.http ] INFO : Starting HTTP server
MWS2-INFO> Stops the managed pool.
15.6814 [terkin.network.core ] ERROR : Starting HTTP server failed
Traceback (most recent call last):
File "network/core.py", line 126, in start_services
File "network/core.py", line 146, in start_httpserver
File "api/http.py", line 70, in start
File "MicroWebSrv2/microWebSrv2.py", line 220, in StartManaged
File "MicroWebSrv2/microWebSrv2.py", line 215, in StartManaged
File "MicroWebSrv2/microWebSrv2.py", line 215, in StartManaged
File "MicroWebSrv2/microWebSrv2.py", line 207, in StartManaged
File "MicroWebSrv2/microWebSrv2.py", line 185, in StartInPool
MicroWebSrv2Exception: Cannot bind server on 0.0.0.0:80.
I believe we had a global variable on the module level to keep a reference to the MicroWebSrv
reference, but this eventually stopped working after upgrading to a more recent version of Pycom MicroPython. We might also be wrong on that so MicroWebSrv
might have been more graceful to us.
We figure it would be the best thing to invoke MicroWebSrv2
before shutting down, i.e. when quitting the program through CTRL+C
or just before the “soft reboot”.
So, we are humbly asking whether you would see a way to get around this issue?
With kind regards, Andreas.
[1] https://github.com/hiveeyes/hiveeyes-micropython-firmware
Issue Analytics
- State:
- Created 4 years ago
- Comments:38 (36 by maintainers)
Top GitHub Comments
All right. I will check this with the next iteration. Thanks again!
Yes, after a soft reset only 👍 Also, thank you for all Andreas!