Some networks block UDP or allow only outbound HTTPS: schools, hospitals, hotels, airports, phone hotspots. On those, a device cannot reach its Nexus server today. This page says what we built for that case, what else we looked at, and why. It builds on the mesh as it is; nothing here replaces a part of it.
What we chose
A WebSocket path on the server's existing HTTPS listener, used only when UDP does not work. UDP stays first. The session survives a change of path.
- Server: two optional WebSocket routes on the listener the API already uses (
/api/transport/ws/dataplane,/api/transport/ws/relay). Off by default. - One message is one datagram. The bridge never decrypts and adds no authority. The dataplane still authenticates every packet, as it does over UDP.
- Client: starts UDP at once and the WebSocket path 250 ms later. The first path to finish a real handshake wins, so a captive portal that only accepts the TCP connection never wins.
- Failover: a probe every 100 ms; after 4 misses the client moves to the other path and keeps the session, with no new handshake. It tries UDP again after a hold-down.
- Relay: device-to-device relay sessions can run over the same WebSocket path.
- Limits: 32 connections, 4 per client address, 90 s idle timeout; an oversized message closes the connection.
- No new dependencies. It uses the HTTP library's WebSocket support that the event socket already uses.
The order a device tries
| Step | Path | When it is used | Status |
|---|---|---|---|
| 1 | Direct UDP | Always tried first | upstream today |
| 2 | UDP relay | Two devices cannot reach each other directly | upstream today |
| 3 | WebSocket over HTTPS | UDP is blocked or dies mid-session | our fork, lab tested |
Other options, and why we did not pick them
| Option | Why not |
|---|---|
| QUIC or HTTP/3 tunnel | It is still UDP. The networks that block the mesh block this too. |
| TURN over TCP/TLS | A second server and protocol to run and secure. The HTTPS listener and its WebSocket support are already there. |
| WebSocket always, no UDP | Simpler, but slower for everyone: 160 to 181 Mbit/s against 463 on UDP in our lab, and a lost TCP segment stalls every stream behind it. |
| New handshake on every path change | Drops open streams. The session already lives below the network stack, so a path change only needs a new endpoint. |
| A third-party tunnel or public relay as the main path | Tunnels carry WebSockets but not UDP, and traffic would cross machines the operator does not own. It can be a backup address, not the design. |
| Disguising traffic, domain fronting, getting past inspection | Out of scope on purpose. This is for networks that allow HTTPS. It does not try to defeat a network's rules, and it looks like what it is: a WebSocket to the Nexus server. |
Measured
Lab: two network namespaces on one host, with the firewall and delay applied on the client side.
| Scenario | Path chosen | First answer | 8 MiB upload |
|---|---|---|---|
| Clean network | UDP | 6 ms | 463 Mbit/s |
| All UDP dropped | WebSocket | 264 ms | 160 Mbit/s |
| Only TCP 443 allowed | WebSocket | 264 ms | 181 Mbit/s |
| 80 ms delay and 2% loss | UDP | 168 ms | 2.6 Mbit/s |
- 30-minute soak: UDP cut 47 times; 60 of 60 streams completed, 0 resets, worst gap 0.86 s.
- Server restart mid-session: back within about 1 s of the server listening.
- Wi-Fi to cellular with UDP blocked at the same moment: 0.8 s outage.
- A capture on the relay link shows ciphertext only. Address and undefined-behaviour sanitizer runs are clean.
What is not proven
- Lab only. Nothing has run across the real internet or behind a real captive portal yet.
- Not switched on in our own network. Our six work servers run this build with the WebSocket path off; devices there use direct UDP.
- Overhead: about 96 bytes per datagram on the WebSocket path with the current HTTP library.
- Threads: the bridge holds one thread per connection, capped at 32.
- Session tokens still expire after 24 h with no refresh. That is separate from this work.
If upstream wants it
- No breaking change. Off by default; the join answer gains optional fields; old clients and servers keep working.
- Size: about 4,900 lines with tests, in two new components (server bridge, client tunnel and path chooser).
- Small fixes that stand alone and can go first: restart recovery (21 s to 1 s), a 41 ms stall on the bridge socket, relay packets 6 bytes over the MTU, backbone links ignoring the announced UDP port, a lost answer on leave.
- Stays in our fork: the operator admission list and removal page. That is our trust model, not Nexus's.
- Code:
festeraeb/lemonade-nexus, branchcesarops/nexus-resiliency-2026-11-12. It would be rebased onto current upstream before any pull request.
Questions and corrections are welcome; Thom posts for CESARops.