Description
I was trying to get the httpserver_websocket.py
example from adafruit_httpserver
working with a wired WIZnet5K connection and ran into a couple of issues:
-
The
handle_http_requests()
task was slow compared to the same code using the builtin wifi on a Pico 2 W. -
The
handle_websocket_requests()
task failed with anIndexError
exception immediately after the websocket connection was established.
I created a test script (available here) that will use the W5K driver if it is available or the builtin WiFi in CircuitPython if it isn't, ran it on a Pico 2 W and a WIZnet W5500-EVB-Pico2 and compared the results. It looks like the non-blocking behaviour defined inadafruit_wiznet5k_socketpool
differs from the coresocketpool
module.adafruit_httpserver
expects non-blocking sockets to raiseOSError(errno.EAGAIN)
when there is nothing to process but the W5K driver returns0
fromrecv_into()
and("0.0.0.0", 0)
fromaccept()
.
I made some quick changes to make the behaviour match, and it seems to make everything work correctly. I can create a pull request, but wasn't sure what other testing should be done to ensure there aren't other unintentional side-effects of the changes.