Skip to content

Instantly share code, notes, and snippets.

@anecdata
Last active November 1, 2022 15:36
  • Star 6 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
RADS: Redundant Array of mDNS http Servers

In the configuration pictured below, multiple identically-configured Adafruit CircuitPython 8.0.0-beta.0 on 2022-08-18; Adafruit QT Py ESP32S2 with ESP32S2 are used to create a Redundant Array of mDNS http Servers. The devices could be physically together or scattered around, as long as they are on the same LAN. Once configured, no USB connection is necessary for operation.

Each is running CircuitPython 8 Web Workflow: https://docs.circuitpython.org/en/latest/docs/workflows.html#web

Web Workflow automatically connects to a Wi-Fi Access Point based on credentials in a /.env file in the root of the CIRCUITPY drive filesystem, and creates an HTTP Server (port can be changed with CIRCUITPY_WEB_API_PORT= in the /.env file; it's port 80 by default).

In code.py, run an HTTP Server using (for example): https://docs.circuitpython.org/projects/httpserver/en/latest/api.html Make sure that the ports are different between the Web Workflow HTTP Server and the code.py HTTP Server (e.g., set the code.py HTTP Server to listen on port 8080).

This allows access to the Web Workflow HTTP Server for the CIRCUITPY filesystem and the code.py HTTP Server for arbitrary response bodies or file serving.

Further, since any one of these devices may respond to http://circuitpython.local:8080 due to automatic mDNS configuration as part of Web Workflow, there is redunancy on the LAN for the features of the code.py server. Typically, hosts will cache the IP address associated with the .local name for about two minutes, so access at any arbitrary time could get a response from any one of the RADS devices. RADS devices can be added or taken away (or go down) at will, but as long as one is up the server features are available.

@anecdata
Copy link
Author

RADS

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment