You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 an IndexError 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 in adafruit_wiznet5k_socketpool differs from the core socketpool module. adafruit_httpserver expects non-blocking sockets to raise OSError(errno.EAGAIN) when there is nothing to process but the W5K driver returns 0 from recv_into() and ("0.0.0.0", 0) from accept().
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.
The text was updated successfully, but these errors were encountered:
@justmobilize Got it. I've found some additional behavioural differences related to the accept() method, though, so I'll try to get those sorted and put it all into one pull request.
fasteddy516
changed the title
Non-blocking socket behaviour differs from core sockets
Socket behaviour differs from core sockets
Mar 22, 2025
I was trying to get the
httpserver_websocket.py
example fromadafruit_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 in
adafruit_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.
The text was updated successfully, but these errors were encountered: