@ai-ecoverse/wasix-websocat
websocat 4.0.0-alpha3, the WebSocket client and server ("netcat for ws://"), built for slicc's kernel as a WASIX program. This is an upstream alpha: websocat v4 has no stable release yet. It's upstream's source with two WASIX patches (subprocesses fail cleanly; see below) and a patch for exit codes and logs (see Exit codes and logs). The build also patches crate wiring and the WASIX fork of mio; see the recipe.
pnpm add -g @ai-ecoverse/wasix-websocat
websocat -s 8080 mirror: # an echo server on the kernel loopback
echo hi | websocat ws://127.0.0.1:8080/ # hi
websocat -b ws://127.0.0.1:8080/ < file # binary messages
Needs slicc-kernel 1.95.0 or later (WASIX epoll and eventfd, slicc-kernel#674).
Networking
websocat v4 opens its own TCP connections and does its own TLS, with rustls and the bundled Mozilla roots (webpki-roots), so wss:// needs no CA setup. It has no HTTP or SOCKS proxy support, so it never goes through the kernel's https_proxy.
- Kernel loopback (
127.0.0.1,localhost) always works. - Other hosts (
ws://example.com/,wss://…) need an exit that gives programs raw TCP: in seven, a linked slicc CLI or a Tailscale exit node (the kernel's uplink). Without one:- a name fails with
No such file or directory (os error 44); - an address fails with
Network unreachable.
- a name fails with
- No TLS server: websocat v4 can't serve
wss://. - What the cert covers through an uplink:
ws://echo, andwss://with-k. That's the TLS handshake and framing against a throwaway CA. Chain verification uses the embedded webpki roots, and is covered by slicc-bios end to end.
Limits on WASIX
- No subprocesses (homescoop#689, #709): websocat's process support doesn't work on this target.
exec:,cmd:andsh-c:are refused at startup (exec:, cmd: and sh-c: are not supported on WASIX), and so is--exec-after-listen. In-xscenario scripts,subprocess_new,subprocess_new_osstrandsystemfail withsubprocesses are not supported on WASIX. Every case exits non-zero, with no panic.
Exit codes and logs
Since 4.0.0-alpha3-7, a failure that upstream v4 only logged exits non-zero, and every log line goes to stderr, so websocat … > out and websocat … | jq carry only data (homescoop#868). RUST_LOG sets the level (RUST_LOG=debug, RUST_LOG=off; default INFO, homescoop#1421):
| Exit | When |
|---|---|
| 14 | a connect is refused or fails (upstream's) |
| 15 | a listener can't bind its address, for example the port is in use (homescoop#696; upstream exits 0) |
| 16 | readfile:, writefile: or appendfile: can't open its file (homescoop#1023; upstream exits 0) |
| 20, 21 | a hostname has no address, or its lookup fails (upstream's) |
websocat 4 is upstream's current line but still a pre-release: options and specifiers differ from websocat 1.x (see websocat --help; for example, there's no -1).