Docs
Inspector
The local web UI and API that show every request and response Hopwire captured, and send them again with Replay and Edit & Replay.
The inspector is a web UI and a small HTTP API that the CLI serves on your machine. It shows every exchange (a request and its response) in the traffic log, live, and can send a stored request again.
It binds to 127.0.0.1 only. It is never reachable from another machine, and there is no option to change that.
Open it
hopwire http, hopwire up and hopwire watch all start the inspector. The last line of the start output is its address:
$ hopwire http 3000
Mode private (local only, no network connection beyond loopback)
Forwarding http://127.0.0.1:4041 -> http://127.0.0.1:3000
Traffic log <log-key> (0 exchanges)
Inspector http://127.0.0.1:4040/<key>
Open that address in a browser, <key> included. http://localhost:4040/<key> works too.
<key> is an access key of 43 characters that the CLI makes up anew at every start. It is printed only in this line and never written to disk. Every page and every API route of the inspector starts with it; without it, or with the key of an earlier run, the inspector answers 403 (see The access key). Reopen the inspector from the Inspector line after every restart.
| Command | Inspector port |
|---|---|
hopwire http <port> |
--inspect <port>, default 4040, 0 picks a free one. --no-inspect runs without the inspector. --inspect and --no-inspect cannot be combined. |
hopwire watch <log-key> |
--inspect <port>, default 4040, 0 picks a free one. |
hopwire up |
inspector.port in hopwire.yaml, default 4040, 0 picks a free one. hopwire up always runs the inspector. |
If the port is taken, the command does not start:
Port 4040 for the inspector is already in use; choose another one with --inspect <port> or run with --no-inspect.
This is what you hit when you run a tunnel and a watch on the same machine. Give one of them another port, for example --inspect 4050.
The inspector shows the traffic log of the data directory, so exchanges from earlier runs are still there after a restart.
The Traffic screen
The inspector has one screen. A status bar on top, the request list on the left, the selected exchange on the right.
Status bar
| Item | Meaning |
|---|---|
| Private mode / Public mode | Public mode when at least one service has a public URL through the edge, otherwise private mode. |
| Watching a shared log | Shown when the inspector was started by hopwire watch. |
| Public URL | One per public service, with a copy button. |
| Peer key | The public key of this machine. Shown when the tunnel is shared, and always in watch mode. Shortened on screen; the copy button copies all 64 characters. |
| Log key | The key of the traffic log shown. In watch mode this is your teammate's log key. |
| Replay target | Where replays go. See Replay target rules. |
| Live / Connecting / Reconnecting / Disconnected | State of the live stream. On Disconnected the page shows "The connection to the tunnel is closed. Reload the page to connect again." |
| Light / Dark | Switches the theme. Dark is the default; the choice is kept in this browser. |
Until the first request arrives, the screen shows "No requests yet" and a curl line for the entry point that you can copy:
$ curl -X POST http://127.0.0.1:4041/hello -H 'content-type: application/json' -d '{"hello":"hopwire"}'
Requests have to go to the entry point (4041 here), not to the service itself. What goes straight to the service does not pass Hopwire and is not recorded.
Request list
Newest first. New exchanges appear as they complete, without a reload. Each row shows:
- the method, the path with its query string, and the response status. The status is coloured by class: 2xx green, 3xx sky, 4xx amber, 5xx red, anything else (such as 101) neutral
- the time of day the request arrived (local time,
HH:MM:SS) and the duration - the source:
local(the loopback entry point),peer(a teammate throughhopwire connect),public(the public URL through the edge) orreplay wsfor a WebSocket handshakeremotefor an exchange from a teammate's log (watch mode)- the service name, when there is more than one service
The list loads the newest 100 exchanges of each log. Load older requests at the end of the list loads the next 100.
A request that was given up before it was answered (the client hung up, the edge cancelled it) is ended at the local service and not recorded, so it does not appear.
Filters
The filter field matches against method, path, status, service name and source. Matching ignores case, looks for the text anywhere in those fields, and with several words every word has to match.
| Type | Shows |
|---|---|
post |
POST requests, and any path that contains "post" |
post 500 |
POST requests answered with 500 |
get /api |
GET requests whose path contains /api |
replay |
replays |
p2p_peer |
requests from teammates |
public_edge |
requests that came in through the public URL |
ws |
WebSocket handshakes (and anything else containing "ws") |
The source is matched by its stored name: local, replay, p2p_peer, public_edge. Typing peer or public matches too, because the filter looks for the text anywhere.
When the tunnel has more than one service, a second control next to the field filters by service (All services or one name).
The filter only looks at the exchanges already loaded into the page. To search further back, load older requests first. When nothing matches, the list says "No request matches the filter."
Request and response tabs
Select a row to see the exchange. The header shows method, path and status, then:
- Time and Duration
- Source and Service
- Origin: remote log, for an exchange from a teammate's log
- Replay of with the first 8 characters of the original's id, for a replay. It is a link when the original is loaded in the list.
Below it, the Request and Response tabs each show:
- Headers, as captured, in their original order, repeated headers included
- Body, with its kind and size (
JSON, 1.2 kB,Text, 48 B,Binary, 3.4 kB) and a Copy body button for JSON and text
A body is shown as JSON when it is valid UTF-8, starts with { or [ and parses; it is then indented for reading. Copy body copies the indented form. Any other valid UTF-8 is shown as text, unchanged. An empty body shows "No body."
Truncated and binary bodies
The 2 MB capture limit
The log keeps at most the first 2 MB (2 * 1024 * 1024 bytes) of each body. The limit applies to the request body and the response body separately.
The limit is about the log only. A larger body is still forwarded in full, in both directions.
A truncated body is marked in its tab:
Truncated: the log keeps only the first 2.0 MB of this body. The full body was forwarded.
A truncated JSON body no longer parses, so it is shown as text.
Binary bodies
A body that is not valid UTF-8, or that contains a NUL byte, counts as binary. It is not shown:
Binary body of 3.4 kB. It is not shown, but it is replayed as captured.
and when it was also truncated:
Binary body; the log keeps its first 2.0 MB. It is not shown.
What this means for replays
| Stored request body | Replay | Edit & Replay |
|---|---|---|
| Complete, JSON or text | yes | yes |
| Complete, binary | yes, sent as captured | yes; the body cannot be edited and is sent as captured |
| Truncated, text | no: "The stored body was truncated. Use Edit & Replay to supply the body." | yes; you supply the body |
| Truncated, binary | no | no: "The stored body is binary and was truncated, so this request cannot be replayed." |
Only the request body matters here. A truncated response body does not stop a replay.
Replay
Replay sends the stored request again, exactly as stored: same method, path, headers and body. It goes through the same interceptor as every other request, so the result is a new exchange in the log with source replay and a Replay of link to the original. The inspector selects the new exchange and opens its Response tab. The terminal prints a line for it like for any request.
Details that matter:
- The
Hostheader goes out as it was captured. A request that came in through the public URL is replayed with the public host name inHost. - Hop-by-hop headers (
Connection,Keep-Alive,Proxy-Authenticate,Proxy-Authorization,Proxy-Connection,TE,Trailer,Transfer-Encoding,Upgrade), any header named inConnection, andExpectare not sent on, as with every forwarded request. Content-Lengthis set to the length of the body that is really sent. A request without a body that had noContent-Lengthgoes out without one.- A replay can be replayed again.
- If the replay target is down, the replay still produces an exchange: status 502 with the body
Hopwire: the local service did not answer (ECONNREFUSED).
Edit & Replay
Edit & Replay opens a form filled with the stored request:
- Method: GET, POST, PUT, PATCH, DELETE, HEAD, OPTIONS, plus the original method if it is another one
- Path: including the query string
- Headers: one row per header. Edit, Remove or Add header. Rows whose name and value are both empty are dropped; a row with a value but no name is refused as an invalid header name. "Content-Length is set to match the body."
- Body: a text field. Format JSON appears when the text parses as JSON and re-indents it. A binary body cannot be edited: "The body is binary and cannot be edited here. It is sent as captured."
Send replay sends it; Cancel closes the form. The stored exchange is never changed: the edit goes out as a new request and comes back as a new exchange.
For a truncated text body the field holds the captured first part, with the note "The log holds only the first part of this body. What you send is exactly the text below." Paste the full body or cut it down to something valid before sending.
The form checks before it sends:
| Message | Cause |
|---|---|
| "Enter a method such as GET or POST." | The method is not a valid HTTP token. |
| "The path must start with / and must not contain spaces." | The path is empty, relative or contains whitespace. |
| "\"X Y\" is not a valid header name." | A header name with characters HTTP does not allow. |
| "The value of X must be a single line." | A header value with a line break. |
Replay target rules
Where a replay goes depends on the command that started the inspector. Next to the buttons the inspector says "Goes to" and the address.
| Started with | A replay goes to | Status bar "Replay target" |
|---|---|---|
hopwire http <port> |
http://127.0.0.1:<port> |
that address |
hopwire up, one service |
the local target of the service |
that address |
hopwire up, several services |
the local target of the service the exchange belongs to | "the local target of each service" |
hopwire watch <log-key> --replay-target <url> |
<url>, for every exchange |
that address |
hopwire watch <log-key> |
nowhere, Replay is off | "none: start hopwire watch with --replay-target <url>" |
A replay always goes to a service on your own machine. It never goes to the public URL, never through the edge, and never to a teammate.
With hopwire http and hopwire up the log may hold exchanges of a service that is not part of the running tunnel, for example from an earlier run with another --name. Those cannot be replayed:
The service "billing" is not part of this tunnel, so there is nothing to replay to.
Watch mode
Private mode: "No account, no servers of ours, end-to-end encrypted between you and the teammates you choose."
hopwire watch <log-key> follows the traffic log of a teammate who runs a shared tunnel (hopwire http <port> --share, or p2p.share in hopwire.yaml) and shows it in an inspector on your machine.
$ hopwire watch <log-key> --replay-target http://127.0.0.1:3000
Mode private (direct P2P: no account, no servers of ours, end-to-end encrypted between you and the teammates you choose)
Watching <log-key> (42 exchanges)
Peer key <your-peer-key>
Replay to http://127.0.0.1:3000
Inspector http://127.0.0.1:4040/<key>
The log key is the 64 hexadecimal characters after Traffic log in your teammate's start output, or the Log key in their inspector. Whoever has it sees everything the log captured, headers and bodies included, unless the sharer restricts access with --allow.
Origin own and remote
In watch mode the inspector shows two logs in one list:
- remote: your teammate's log. Rows carry a
remotetag, the detail view says Origin: remote log. It is read-only; nothing you do writes to it. - own: the traffic log of your own data directory. Your replays land here, with source
replay.
So when you replay a remote exchange, the original stays in the remote log and the result appears as a new row without the remote tag. Your teammate does not see your replays.
The two logs are loaded and paged separately, 100 exchanges each, and merged by time.
Replaying a teammate's request against your own service
--replay-target takes an http URL on this machine without a path:
$ hopwire watch <log-key> --replay-target http://127.0.0.1:3000
Anything else is refused:
--replay-target must be an http URL on this machine without a path, for example http://127.0.0.1:3000
Every replay goes to that one target, whichever service the exchange belonged to on your teammate's side. The replay keeps the service name of the original.
Without --replay-target you can read everything but both buttons are off:
Replay is off because this watch has no replay target. Start hopwire watch with --replay-target <url>.
When the teammate goes offline
What has already been replicated stays on your machine and stays visible. Blocks of the remote log that have not arrived are left out of the list, and an exchange whose block is not on your machine cannot be replayed.
WebSocket handshakes (101)
A WebSocket that passes the tunnel is recorded as one exchange: the opening handshake, with status 101, the request and response headers, empty bodies, and the time until the 101 as its duration. The row carries a ws tag.
The messages of the connection are not recorded. That is why a handshake has neither button:
A WebSocket handshake cannot be replayed: the messages of the connection are not recorded.
A replay would open a connection and then have nothing to send on it.
An upgrade request that the local service answers with anything other than 101 is an ordinary exchange with that status, and can be replayed like one.
API
Everything the UI does goes through four routes under /<key>/api. They work with --inspect on any port, and they work when the UI files are missing.
Every route starts with the inspector address from the start output, access key included. The examples keep it in a variable:
$ INSPECTOR=http://127.0.0.1:4040/<key> # the Inspector line of the start output
On a machine that other users share, the arguments of a running curl are visible to them in ps. Pass the address through a config file or standard input instead (curl -K - with url = "...").
All answers are JSON (except the stream) and carry Cache-Control: no-store. Errors have this shape:
{ "error": "unknown_exchange", "message": "No exchange with this id is in the log" }
The examples use jq to read the JSON.
GET /api/status
$ curl -s "$INSPECTOR/api/status"
{
"mode": "private",
"services": [
{ "name": "default", "target": "http://127.0.0.1:3000", "entryUrl": "http://127.0.0.1:4041" }
],
"replayTarget": "http://127.0.0.1:3000",
"logKey": "<log-key>",
"peerKey": null,
"publicUrls": [],
"watching": false
}
| Field | Meaning |
|---|---|
mode |
"private" or "public" |
services |
Name, local target and loopback entry point of each service. Empty in watch mode. |
replayTarget |
The one replay target, or null. It is null with several services (each exchange goes to its own service) and in watch mode without --replay-target. |
logKey |
Key of the log shown. In watch mode, the teammate's log key. |
peerKey |
Public key of this machine; null when the tunnel is not shared. |
publicUrls |
Public URLs of the public services. |
watching |
true when started by hopwire watch. |
GET /api/exchanges
The newest exchanges, newest first.
| Parameter | Values | Default |
|---|---|---|
limit |
whole number, 1 to 500 | 100 |
before |
whole number, 0 or more: only blocks with an index below it | the end of the log |
origin |
own or remote |
every log |
$ curl -s "$INSPECTOR/api/exchanges?limit=1"
[
{
"index": 7,
"origin": "own",
"exchange": {
"id": "0b9c1a52-6f0e-4c58-9a44-2f6f6f3f0d11",
"timestamp": 1795000000000,
"serviceName": "default",
"source": "local",
"request": {
"method": "POST",
"path": "/hello",
"headers": [["Host", "127.0.0.1:4041"], ["content-type", "application/json"], ["Content-Length", "19"]],
"bodyBase64": "eyJoZWxsbyI6ImhvcHdpcmUifQ==",
"bodyTruncated": false
},
"response": {
"status": 200,
"headers": [["content-type", "application/json"]],
"bodyBase64": "eyJvayI6dHJ1ZX0=",
"bodyTruncated": false,
"durationMs": 12
}
}
}
]
indexis the position of the block in its log;originsays which log.timestampis epoch milliseconds at which the request arrived.sourceislocal,p2p_peer,public_edgeorreplay. A replay also hasreplayOf, the id of the exchange it was made from.headersare[name, value]pairs, as captured.- Bodies are Base64, at most the captured 2 MB each.
Paging: take the lowest index you received and pass it as before. In watch mode page each log on its own with origin, because an index belongs to one log:
$ curl -s "$INSPECTOR/api/exchanges?origin=remote&limit=100&before=250"
One answer carries at most 16 MB of bodies per log (but always at least one exchange), so a page of large exchanges can be shorter than limit. A short page is not the end of the log; index 0 is.
A bad parameter is a 400 with invalid_request, for example "limit must be a whole number between 1 and 500" or "origin must be own or remote".
Print one line per exchange:
$ curl -s "$INSPECTOR/api/exchanges?limit=20" \
| jq -r '.[] | "\(.exchange.request.method) \(.exchange.request.path) \(.exchange.response.status)"'
Decode the body of the newest request:
$ curl -s "$INSPECTOR/api/exchanges?limit=1" \
| jq -r '.[0].exchange.request.bodyBase64' | base64 --decode
GET /api/stream
A server-sent event stream (text/event-stream). It starts with a : connected comment, sends one exchange event for every exchange appended to a log from then on, and a : heartbeat comment every 15 seconds.
$ curl -N "$INSPECTOR/api/stream"
: connected
event: exchange
data: {"index":8,"origin":"own","exchange":{...}}
: heartbeat
The data line is one record, the same shape as an element of /api/exchanges. The stream does not send what is already in the log: load that with /api/exchanges after the stream is open. A client that falls more than 64 MB behind is disconnected.
POST /api/replay/:id
Sends the stored request with this id again. The answer is the new exchange (the same shape as exchange above, with source: "replay" and replayOf), sent once the response of the replay target is complete.
Without a body, the request goes out as stored:
$ id=$(curl -s "$INSPECTOR/api/exchanges?limit=1" | jq -r '.[0].exchange.id')
$ curl -s -X POST "$INSPECTOR/api/replay/$id" | jq '.response.status'
With a JSON body, you change it. Every field is optional; what you leave out is taken from the stored request.
| Field | Type | Notes |
|---|---|---|
method |
string | Upper-cased before sending. CONNECT is refused. |
path |
string | Must start with /, no spaces. Includes the query string. |
headers |
list of [name, value] pairs |
Replaces the whole header list, it is not merged. |
bodyBase64 |
string | The new body as padded Base64. "" sends no body. |
Content-Length is set from the body that is sent, so you do not have to correct it. It is only left out when the body is empty and the headers had none.
Replay with another body:
$ body=$(printf '%s' '{"hello":"again"}' | base64)
$ curl -s -X POST "$INSPECTOR/api/replay/$id" \
-d "{\"bodyBase64\":\"$body\"}" | jq '.response.status'
Replay to another path:
$ curl -s -X POST "$INSPECTOR/api/replay/$id" -d '{"path":"/hello?debug=1"}'
Replay the newest request that was answered with a 5xx:
$ id=$(curl -s "$INSPECTOR/api/exchanges?limit=500" \
| jq -r '[.[] | select(.exchange.response.status >= 500)][0].exchange.id')
$ curl -s -X POST "$INSPECTOR/api/replay/$id" | jq '.response.status'
A replay that reaches the API is answered with HTTP 200 whatever the replay target said; the target's status is response.status in the answer. A target that is down gives 200 with response.status 502.
Errors:
| Status | error |
When |
|---|---|---|
| 400 | invalid_json |
The body is not valid JSON. |
| 400 | invalid_request |
An unknown field, a field of the wrong type, or a method, path or header that cannot be sent. |
| 404 | unknown_exchange |
No exchange with this id is in the log. |
| 409 | no_replay_target |
Watch mode without --replay-target, or the exchange's service is not part of this tunnel. |
| 413 | request_too_large |
The replay request is larger than 16 MB. |
| 422 | websocket_handshake |
The exchange is a WebSocket handshake (status 101). |
| 422 | body_truncated |
The stored body was truncated and you sent no bodyBase64. |
| 500 | log_failed |
The replay was sent but could not be written to the traffic log. |
Other answers of the API: 404 not_found for an unknown route, 405 method_not_allowed (with an Allow header) for the wrong method.
The access key
The inspector shows credentials: whatever was in the headers and bodies that passed. Binding to 127.0.0.1 keeps other machines out; the access key keeps out other programs on your machine and web pages in your browser that do not know it.
Every path must start with /<key>/. Anything else (no key, a wrong key, the key of an earlier run) is answered:
$ curl -s http://127.0.0.1:4040/api/status
{"error":"forbidden_key","message":"Open the inspector at the address hopwire printed: it carries the access key of this run"}
/<key> without the trailing slash redirects to /<key>/. The key is compared in constant time and never appears in an answer. Every answer carries Referrer-Policy: no-referrer, so the address with the key does not leave in a Referer header.
Who can read your terminal, your browser history or the arguments of a running curl learns the key of that run. It ends with the run.
The Host and Origin checks
Two further checks keep web pages in your own browser out.
Host. Every request must carry a Host header of exactly 127.0.0.1:<port> or localhost:<port>, with the inspector's port. Anything else is refused:
$ curl -s -H 'Host: example.com' "$INSPECTOR/api/status"
{"error":"forbidden_host","message":"The inspector only answers on its loopback address"}
This stops DNS rebinding, where a page on another site points its own host name at 127.0.0.1 to read your inspector. It also means a reverse proxy or a custom host name in front of the inspector does not work unless it sends one of the two Host values.
Origin. A request that is not GET or HEAD and carries an Origin header is refused unless the origin is http://127.0.0.1:<port> or http://localhost:<port>. A request that is not GET or HEAD and that the browser marks Sec-Fetch-Site: cross-site or same-site is refused the same way, also without Origin:
$ curl -s -X POST -H 'Origin: https://example.com' "$INSPECTOR/api/replay/some-id"
{"error":"forbidden_origin","message":"The inspector does not accept requests from other sites"}
This stops a page on another site from triggering replays against your local service. Scripts are not affected: curl and most HTTP clients send no Origin header, and a request without one passes.
Besides the two checks, every answer carries X-Content-Type-Options: nosniff and Cross-Origin-Resource-Policy: same-origin, and the UI is served with a Content-Security-Policy that loads nothing from other origins and forbids framing. The API sends no CORS headers, so a page on another origin cannot read its answers.
Troubleshooting
| You see | Cause and fix |
|---|---|
| "Port 4040 for the inspector is already in use; ..." | Another tunnel or watch already has the port. Use --inspect <port>, or inspector.port in hopwire.yaml. |
| "Not connected to the tunnel" and "The tunnel does not answer. Is it still running?" | The CLI is not running on this port. Start it and reload the page. |
| "The connection to the tunnel is closed. Reload the page to connect again." | The stream ended for good. Reload. |
| The list stays empty | Requests are going straight to the service. Send them to the entry point (the Forwarding line), the public URL or through hopwire connect. |
{"error":"forbidden_key",...} (403) |
The address has no access key or the key of an earlier run. Open the address of the Inspector line of the current start output. |
{"error":"forbidden_host",...} |
You opened the inspector under another host name or port mapping. Use http://127.0.0.1:<port>/<key>. |
{"error":"ui_not_built",...} (503) |
The UI files are missing from this build of the CLI. The API under /<key>/api still works. |
| Replay is greyed out | The reason is printed under the buttons: no replay target, a truncated body, a WebSocket handshake, or a service that is not part of this tunnel. |