Pi Pico W, will only serve a single request and then stops #166
Replies: 2 comments 2 replies
-
Probably similar or at least related to #89. The issue is that some browsers have a performance optimization in which they open a connection and keep it open to have it ready when they need to send a new request to the server. This is problematic when using the synchronous version of Microdot because only one connection can be handled. In an attempt to outsmart browsers I have added a timeout on all connections, so that any connections that are open and don't send a request shortly after are closed. This appeared to have addressed the problem, in fact I haven't heard of any more issues with this since I added the timeout. One thing you can try to determine if it is really the browser messing up with connections causing this is to start the server and then send a request from The easiest way to address this problem is to use the async version of Microdot, which can handle multiple connections concurrently. |
Beta Was this translation helpful? Give feedback.
-
@miguelgrinberg given this constraint, I think you should consider dropping sync support and make Microdot an async only framework? It would significantly simplify the code, tests, and documentation. It would also simplify enhancements and reduce the time you spend on support. Largely it is inexperienced coders who start with a sync approach anyhow so you may also reduce the beginner Python questions you often have to deal with around here. Microdot is a jewel in the MicroPython world so just thinking about how your time here can be made more effective. |
Beta Was this translation helpful? Give feedback.
-
I have implemented the "hello world" with Debug True, I successfully connect to my WiFi network, point a browser at the IP address of 192.168.178.126 and it logs: "Starting threaded server on 0.0.0.0:80...", "GET / 200" and I see "Hello, from Pico"
If I resubmit the request from the browser, there is no response. Nothing is logged to show the request has been received, the browser times out - the site can not be reached.
I am running it from Thonny, Micro Python 2023/04/26 (and I have tried with the latest nightly build).
The only solution is to disconnect the Pi from USB, reconnect it and rerun.
Any ideas?
Beta Was this translation helpful? Give feedback.
All reactions