Same pattern as the Express example, but the HTTP side is Fastify so
you also see its structured pino logger and per-request req.id.
attachArcpToFastify(app, { path, allowedHosts, onTransport }) mounts
the WS upgrade handler on the app.server (the Node http.Server
Fastify created). Fastify's request pipeline is never consulted for
the upgrade — Node's http.Server emits upgrade before any Fastify
route runs.
In one terminal:
pnpm tsx examples/fastify/server.tsIn a second terminal:
pnpm tsx examples/fastify/client.tsThe client makes GET /health (the response includes Fastify's
req_id, generated by genReqId), then opens an ARCP WebSocket on the
same port and submits an echo job. Stop the server with Ctrl+C.
- One Node HTTP server, two protocols on one port (Fastify HTTP + ARCP).
- Fastify's structured pino logger writing alongside ARCP's own logs.
- Fastify-style per-request id propagated to the
/healthbody. - DNS-rebinding protection via
allowedHostson the upgrade.
| Env var | Default | Used by |
|---|---|---|
ARCP_DEMO_PORT |
7897 |
both |
ARCP_DEMO_URL |
ws://127.0.0.1:7897/arcp |
client |
ARCP_DEMO_TOKEN |
demo-token |
both |