muxws
Multiplexed streams over one WebSocket, with HTTP/2 and HTTP/3 stream semantics. muxws carries many
independent, cancellable, bidirectional streams on one socket; either end can open a stream. It needs no
QUIC or HTTP/3 stack. muxws is defined by its wire format. Python and TypeScript implementations are in
this repository; SPEC.md and
conformance/ specify the protocol
for further implementations.
muxws copies the stream semantics of HTTP/2 and HTTP/3, not their transport. A connection runs over one TCP socket or one Unix domain socket, so all streams share one global message order and there is no per-stream loss recovery. Rationale lists which parts of the HTTP model muxws copies and which it does not; Comparison compares the two protocols frame by frame. muxws does not route requests, serialize domain objects, authenticate peers, store messages durably or define RPC services.
Install
pip install muxws # extras: [starlette], [websockets], [msgpack]
npm install muxws # optional peers: ws, @msgpack/msgpack
Example
A FastAPI acceptor (pip install "muxws[starlette]" fastapi uvicorn) that answers one payload with one
reply and another with a stream of chunks:
from fastapi import FastAPI, WebSocket
from muxws import accept, Stream
app = FastAPI()
async def on_stream(payload: object, stream: Stream) -> None:
if payload == {"say": "hello"}:
await stream.reply({"greeting": "hello, muxws"})
elif isinstance(payload, dict) and isinstance(payload.get("count"), int):
for n in range(1, payload["count"] + 1):
await stream.send({"chunk": n})
await stream.end()
@app.websocket("/ws")
async def muxws_endpoint(websocket: WebSocket) -> None:
peer = await accept(websocket)
peer.on_stream(on_stream)
await peer.serve()
A Node dialer (npm install muxws ws); a browser imports connect from muxws instead:
import 'muxws';
import { connect } from 'muxws/node';
const peer = await connect('ws://127.0.0.1:8000/ws');
const answer = await peer.request<{ greeting: string }>({ say: 'hello' }, { timeoutMs: 5000 });
for await (const chunk of peer.open<{ chunk: number }>({ count: 3 }, { end: true })) {
console.log(chunk.chunk);
}
await peer.close();
The Getting started guide runs both and adds a Python dialer.
Documentation
The manual is at docs.velis.si/muxws. npm run docs:dev builds and
serves it locally.
| A server and a client in three files | Getting started |
| A browser demo, a Unix-socket demo and a throughput benchmark | Demos |
| Every public symbol in both languages | API reference |
| The normative rules and the conformance fixtures for new implementations | SPEC.md, conformance/ |
| Changes per release, and the changes required when upgrading | Changelog, Migration guide |
Demo
Run locally
Requirements: uv, Node 22+.
git clone https://github.com/velis74/muxws.git && cd muxws
uv sync
npm ci
uv run python demo.py --browser # then open http://127.0.0.1:5173
Status
Alpha. The wire protocol and the packages are versioned independently:
- Wire protocol: generation 1, frozen. The WebSocket subprotocol is
muxws.v1.<codec>. Thev1changes only with a breaking wire change. - Packages: version 0.x. Version 1.0 follows the first confirmed production deployment.
Packages: muxws on PyPI; muxws on npm, with the browser entry point and the muxws/node and
muxws/msgpack subpaths.
Licence
MIT. Copyright © 2025 Jure Erznožnik.
Metadata
Release files for muxws 0.4.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| muxws-0.4.6.tar.gz | 101.1 kB | Without provenance | Details for muxws-0.4.6.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| muxws-0.4.6-py3-none-any.whl | Python 3 | none | any | Details for muxws-0.4.6-py3-none-any.whl |
Total release size: 185.0 kB
Release files / muxws-0.4.6.tar.gz
| Download URL | muxws-0.4.6.tar.gz |
|---|---|
| Size | 101.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
11167a6ba24354fe327ad41e7b9b86e24b05ae457a379107f23b135283b78b50
|
|
BLAKE2b-256 checksum How to use checksums |
9604f2d7cead88cd841816d94430eb779ad9dffce95694852e534fc930aa7513
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.13.6 {"installer":{"name":"uv","version":"0.13.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / muxws-0.4.6-py3-none-any.whl
| Download URL | muxws-0.4.6-py3-none-any.whl |
|---|---|
| Size | 83.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3a767285ee02c92514235dd5337672b44de4b1510afe2c516367a816b556252c
|
|
BLAKE2b-256 checksum How to use checksums |
258ceeb720d3d32c7369a1509336d97387c5132ff09e8f6d4fd3e510d14174e4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.13.6 {"installer":{"name":"uv","version":"0.13.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Security for muxws 0.4.6
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.