circuitpython: httpserver simpletest fails (cp9 on Pico W)

CircuitPython version

dafruit CircuitPython 9.0.0 on 2024-03-19; Raspberry Pi Pico W with rp2040

Code/REPL

import socketpool
import wifi

from adafruit_httpserver import Server, Request, Response

ssid = "Unintended Consequences"
password = "xxxx"

print("Connecting to", ssid)
wifi.radio.connect(ssid, password)
print("Connected to", ssid)

pool = socketpool.SocketPool(wifi.radio)
server = Server(pool, "/static", debug=True)


@server.route("/")
def base(request: Request):
    """
    Serve a default static plain text message.
    """
    return Response(request, "Hello from the CircuitPython HTTP Server!")


server.serve_forever(str(wifi.radio.ipv4_address))

Behavior

code.py output: Connecting to Unintended Consequences Connected to Unintended Consequences Traceback (most recent call last): File “code.py”, line 25, in <module> File “adafruit_httpserver/server.py”, line 185, in serve_forever File “adafruit_httpserver/server.py”, line 228, in start File “adafruit_httpserver/server.py”, line 207, in _create_server_socket OSError: [Errno 95] EOPNOTSUPP

Description

Test code taken from first example here: https://docs.circuitpython.org/projects/httpserver/en/latest/examples.html

Additional information

No response

About this issue

  • Original URL
  • State: closed
  • Created 3 months ago
  • Comments: 17 (5 by maintainers)

Most upvoted comments

Dan commented in another thread that adafruit_httpsrver does not need to use ConnectionManager.

I meant that the actual adafruit_httpserver library does not need ConnectionManager internally. But it’s fine and useful to use ConnectionManager in a test program. ConnectionManager makes it easy to get the socketpool and the ssl context.

If you want to open a new PR to use ConnectionManager in a simpletest or other example, I think that’s a fine idea.

#9084 is meant to fix this. Could you someone test the build artifact? Thanks. https://github.com/adafruit/circuitpython/actions/runs/8421732172?pr=9084