Hopwire Hopwire

Docs

Public mode

Give a local service a public HTTPS URL through the Hopwire edge. Accounts, login, subdomains, Basic Auth, forwarded headers, timeouts, limits, WebSockets and what every error answer means.

Hopwire starts in private mode. No account, no servers of ours, end-to-end encrypted between you and the teammates you choose. Nothing but loopback is opened unless you ask for more.

Public mode is the part you opt into with --public. It gives the local service a public HTTPS URL, so a webhook sender, a phone or a colleague without Hopwire can reach it. It works differently from private mode, and the claim above does not apply to it:

  • It needs an account and an API token.
  • Requests pass through the edge (a Cloudflare Worker). TLS ends there, and the request travels on to your machine over a WebSocket that the CLI opened outbound.
  • The edge stores no request or response content. Its log lines hold the subdomain, a request id, the status, the duration and an error code. No paths, no headers, no bodies.

Everything else stays as it is: every request still goes through the inspector and the local traffic log, and you can combine --public with --share.

Note

Addresses on this page: public tunnels are served under hwr.sh, the edge is wss://edge.hwr.sh, and the control plane (the web app with your account) is https://hopwire.to. The domains are registered, but nothing is deployed on them yet: today public mode runs against a local edge (see Running the edge on your own machine).

Quick start

sh
# once per machine
$ hopwire login

# every time
$ export HOPWIRE_EDGE_URL=wss://edge.hwr.sh
$ hopwire http 3000 --public
text
Mode         public (public URL through the edge; needs a token, requests pass through the edge)
Forwarding   http://127.0.0.1:4041 -> http://127.0.0.1:3000
Public URL   https://t-k3v9qzr2m7xa.hwr.sh
Usage        free plan, today (UTC): 0 of 2,000 requests, 0 B of 200 MB, 0 s of 20 min in flight, 1 of 1 tunnel online; resets at 00:00 UTC
Traffic log  <log-key> (0 exchanges)
Inspector    http://127.0.0.1:4040/<key>

Each request then prints one line with method, path, status and duration:

text
POST    /webhooks/stripe  200  41ms

Stop the tunnel with Ctrl-C. The public URL answers 502 from that moment on.

Accounts and API tokens

Public mode needs an account at the control plane. The control plane is outside the data path: it knows your account, your organisations and their members, plans, API tokens and subdomains, and it never sees traffic.

Every account has a personal organisation, created with it. Plans, limits, names and API tokens belong to an organisation, not to a machine or a person. You can create further organisations and invite members to them.

  1. Register and sign in at the control plane.
  2. Open the API tokens page and create a token. It starts with hw_ and has 43 characters. It is shown once, right after you create it. Only its hash is stored. The token acts in the organisation it was created in, and stops working when you leave that organisation.
  3. Hand it to the CLI with hopwire login.

Revoke a token on the same page. A password reset revokes every token of the account.

hopwire login

sh
$ hopwire login
text
API token (input is hidden):
Logged in    [email protected] at https://hopwire.to
Organisation Your Name's organisation (free plan); the token acts in this organisation
Token        stored in /home/you/.hopwire/config.json (readable for this user only)

What it does:

  • It asks for the API token without showing it. In a script or CI job there is no terminal to ask on, so pass the token in HOPWIRE_TOKEN:

    sh
    $ HOPWIRE_TOKEN=hw_EXAMPLE... hopwire login
  • It checks the token with the control plane. Nothing is stored unless the control plane accepted it.

  • It writes the token and the URL of the control plane to config.json in the data directory, readable for your user only (mode 0600). The data directory is ~/.hopwire, or $HOPWIRE_HOME, or what you pass with --data-dir <path>.

  • The token is never printed, not in errors either.

Rules for --api:

  • An http:// or https:// URL without a path.
  • https:// is required unless the control plane runs on this machine. Over http:// the API token would travel unencrypted.
  • Without --api the login goes to the control plane of the last login on this machine (kept also after a logout), and on the first login to the hosted one, https://hopwire.to. Pass --api only for another control plane, such as one on your own machine (hopwire login --api http://localhost:8089).
Message What to do
That is not an API token: one starts with hw_ and has 43 characters; ... Copy the token again from the API tokens page. It is only shown right after you create it, so create a new one if it is gone.
The control plane at <url> does not accept the API token (401): it is unknown or was revoked; ... Create a new token and run hopwire login again.
The control plane at <url> cannot be reached (<code>); ... Check the URL and your connection.
hopwire login has no terminal to ask for the API token on; pass it in the environment variable HOPWIRE_TOKEN. Set HOPWIRE_TOKEN.

hopwire logout

sh
$ hopwire logout
text
Logged out   the token was removed from /home/you/.hopwire/config.json; it stays valid until you revoke it on the API tokens page of the control plane

Logout removes the token from this machine and nothing else. It does not contact the control plane. To make the token useless everywhere, revoke it on the API tokens page.

If no token was stored, it says so: Logged out no token was stored in <file>.

--public

sh
$ hopwire http <port> --public

--public serves the service under a public URL through the edge. It needs two things:

Needs Where it comes from
The URL of the edge The environment variable HOPWIRE_EDGE_URL. A ws:// or wss:// URL without a path. wss:// is required unless the edge runs on this machine.
A token Your account: run hopwire login first.

When the tunnel starts, the CLI asks the control plane for a short-lived connect token for one subdomain and opens the WebSocket to the edge with it. The token also carries your organisation, its plan and the plan's limits, so the edge enforces them without asking the control plane. A connect token is valid for 300 seconds. The CLI renews it on the open connection when half of that time has passed, so a tunnel runs for as long as you leave it running. You never see or handle connect tokens.

--public works together with the other options of hopwire http:

sh
$ hopwire http 8080 --public --listen 4051 --inspect 4050 --name api
$ hopwire http 3000 --public --share

With --share the first line reads Mode public and private P2P (public URL through the edge, plus direct P2P with the teammates you choose).

For several services at once, use hopwire.yaml and hopwire up. There the edge comes from edge.url and the account from controlPlane.url, and a service is public with public: true:

yaml
version: 1

edge:
    url: wss://edge.hwr.sh

controlPlane:
    url: https://hopwire.to

services:
    web:
        local: http://127.0.0.1:3000
        public: true

controlPlane.url has to be the control plane this machine is logged in to. If it is another one, hopwire up stops and names both.

Messages at the start:

Message What to do
--public needs the URL of the edge: set HOPWIRE_EDGE_URL, ... Set HOPWIRE_EDGE_URL.
HOPWIRE_EDGE_URL must be a ws:// or wss:// URL without a path, ... Remove the path, or correct the scheme.
HOPWIRE_EDGE_URL must use wss:// unless the edge runs on this machine; ... Use wss://.
--public needs an account: run hopwire login first. ... Run hopwire login.
The edge at <url> cannot be reached (<code>); check the edge URL and that the edge is running. Check HOPWIRE_EDGE_URL and your connection.
The edge at <url> refused the token (401), and a new one from the control plane as well; check that this edge belongs to the control plane you are logged in to. The edge and the control plane do not belong together. Check both URLs.
The control plane at <url> limits how often a connect token can be asked for (429); wait a minute and try again. The control plane issues at most 30 connect tokens a minute per API token. Wait a minute.
Your organisation is suspended, so it cannot open public tunnels. Its owner has been told why by email. (organisation_suspended) The organisation gets no connect tokens while it is suspended. Its owner finds the reason in that email.
Your organisation already has <n> of <limit> tunnels online, the most its plan allows at once; stop one of them and start this one again. All tunnels the plan allows are online (see Limits per plan). The CLI does not retry.

A wrong command line exits with code 2, every other failure with code 1. Each is one sentence on stderr.

--subdomain and the URL you get

Without --subdomain

The tunnel is served under the fixed URL of your organisation: t- followed by 12 lowercase letters and digits, for example https://t-k3v9qzr2m7xa.hwr.sh.

  • Every organisation has one, on every plan. The control plane assigns it when the organisation is created, and it stays the same on every start, so you can paste it into a webhook sender once and leave it there.
  • A running tunnel keeps its URL. Reconnects and token renewals do not change it.
  • The fixed URL belongs to the organisation for as long as the organisation exists, and is never given to another one. Nobody can reserve a name that starts with t-.
  • Like every subdomain, it serves one tunnel at a time (see One tunnel per subdomain). To run several public services at once, give the others reserved names.

With HOPWIRE_DEV_TOKEN (a local edge without a control plane, see Running the edge on your own machine), the CLI makes up a random t- name instead, new on every start.

With --subdomain

sh
$ hopwire http 3000 --public --subdomain demo-api
text
Public URL   https://demo-api.hwr.sh

The name has to be reserved by your organisation first. The owner or an admin of the organisation reserves it on the Subdomains page of the control plane. The page shows the public URL of each name and how many of the organisation's names are used. Reserved names come with Pro and Team (see Names by plan).

Rules for a name:

  • 3 to 63 characters: lowercase letters, digits and hyphens.
  • It must not start or end with a hyphen.
  • It must not start with t-.
  • It must not be one of the reserved names: www, api, app, edge, admin, mail, status, docs, hopwire.

How many names an organisation can hold depends on its plan: none on Free, 5 on Pro, 25 on Team. At most 10 new reservations per organisation per calendar month (UTC) are possible, released ones included. Release a name on the Subdomains page to free a slot. A released name stays your organisation's: you can reserve it again, and no other organisation ever can.

--subdomain only works together with --public. In hopwire.yaml the key is services.<name>.subdomain, and two services of one file cannot share a name.

Message What to do
--subdomain must be 3 to 63 lowercase letters, digits or hyphens, must not start or end with a hyphen, must not start with t- and must not be a reserved name such as www or api Pick a name that fits the rules.
Your organisation at <url> has not reserved the subdomain <name> (403); reserve it on the Subdomains page there, or leave the subdomain out to use the fixed URL of your organisation. Reserve the name, or drop --subdomain.
This name is still your organisation's, but its current plan has no room for it, so it is offline. ... (name_not_in_plan) The organisation holds more names than its plan allows, for example after a downgrade. Use the fixed URL, release a name, or move to a plan with more names.
--subdomain only works together with --public Add --public.

One tunnel per subdomain

A subdomain serves one tunnel. The newest connection wins: when a second tunnel starts on the same name, the edge closes the first one, and the first CLI stops with exit code 1 and this line:

text
Another tunnel connected for the subdomain demo-api and replaced this one; stop one of the two or use another subdomain.

Requests that were in flight on the first tunnel get 502.

Names by plan

  • Every plan: one fixed public URL per organisation, a t- name that is tied to the organisation. hopwire http 3000 --public without --subdomain gives you the same URL on every start.
  • Free: the fixed URL only, no reserved names.
  • Pro: the fixed URL, plus up to 5 reserved names of your choice. Team: up to 25. --subdomain is for these names. At most 10 new reservations per organisation per calendar month.
  • A name your organisation held is never given to another organisation, whether you release it or the plan ends. The same holds for the fixed URL. If you delete the organisation, its names are released and stay retired for good.
  • Names above what the plan allows (after a downgrade) stay yours but go offline: the oldest names the plan has room for are served, and a tunnel on one of the others is refused with the name_not_in_plan sentence above. Release a name that is online, and the oldest offline one comes back.

Basic Auth

A public URL is open to everyone who knows it. Basic Auth lets the edge ask for a user and a password before a request reaches your machine.

It is set per service in hopwire.yaml. hopwire http has no option for it.

yaml
version: 1

edge:
    url: wss://edge.hwr.sh

controlPlane:
    url: https://hopwire.to

services:
    api:
        local: http://127.0.0.1:8080
        public: true
        subdomain: demo-api
        auth:
            basic: demo:change-me
sh
$ hopwire up
text
Public URL   https://demo-api.hwr.sh (asks for the user and password of auth.basic)
sh
$ curl -u demo:change-me https://demo-api.hwr.sh/health

How it works:

  • The value is user:password. The user contains no colon, the password may. No control characters, at most 512 bytes.
  • The CLI sends the credentials to the edge once, when it connects. The edge keeps only their SHA-256 hash and compares every public request against it.
  • A request without the right credentials gets 401 Authentication required with WWW-Authenticate: Basic realm="Hopwire". It never reaches your machine and does not show up in the inspector.
  • The edge removes the Authorization header from requests it let through. Your local service does not see the credentials. This also means the service cannot use the Authorization header for its own purposes on a URL with Basic Auth.
  • WebSocket upgrades are asked for the same credentials.
  • The password is never printed. hopwire.yaml then holds a password, so keep it out of version control.

Basic Auth protects the public URL only. The loopback entry point and teammates who reach the service over P2P are not asked.

The edge

The edge is one Worker in front of every tunnel and one object per subdomain that holds the WebSocket of your CLI.

  1. A client sends a request to https://<subdomain>.hwr.sh.
  2. The Worker reads the subdomain from the host name and hands the request to the object of that subdomain.
  3. The object checks Basic Auth when the service asked for it, then sends the request to your CLI as frames over the WebSocket.
  4. The CLI runs it through the same interceptor as every other request: forward to the local service, measure, capture bodies up to 2 MB, append to the traffic log, show in the inspector.
  5. The response goes back the same way.

Things to know:

  • The connection is outbound. The CLI opens the WebSocket to the edge. You open no port and change no firewall rule.

  • Bodies are streamed in both directions in 64 KB chunks with flow control. A slow client slows the local service down instead of filling memory, and the other way round. Bodies larger than the 2 MB capture cap are still proxied in full. Only the copy in the traffic log is cut.

  • Compressed responses are passed on as the service sent them.

  • Repeated headers stay apart. Two Set-Cookie headers arrive as two.

  • Keepalive. The CLI pings the edge every 25 seconds. After two pings without an answer it drops the connection and connects again.

  • Reconnect. When the connection to the edge is lost, the CLI tries again with a wait that doubles from 0.5 seconds to at most 30 seconds, with jitter. The URL stays the same. While the tunnel is away, the public URL answers 502.

    text
    Edge         connection lost; the public URL is offline, next attempt in 0.4 s
    Edge         connected again; the public URL is served
  • No content at the edge. The edge does not store requests or responses, and neither does the control plane. The record of your traffic is the Hypercore log on your machine.

  • HTTP and WebSocket only. No raw TCP or UDP. An upgrade request for anything but a WebSocket gets 501.

Headers your service sees

Header Value
Host Unchanged: the public host name the client asked for, for example demo-api.hwr.sh.
X-Forwarded-Host The same host name.
X-Forwarded-Proto https when the edge is reached over wss://, http for a local edge over ws://.
  • Values a client sent as X-Forwarded-Host or X-Forwarded-Proto are replaced, so your service can rely on them.
  • Hopwire does not set X-Forwarded-For.
  • Hop-by-hop headers do not travel through the tunnel: Connection, Keep-Alive, Proxy-Authenticate, Proxy-Authorization, Proxy-Connection, TE, Trailer, Transfer-Encoding, Upgrade, and every header named in Connection. A WebSocket upgrade keeps Connection and Upgrade.
  • Authorization is removed on a URL with Basic Auth (see above). Without Basic Auth it passes through unchanged.
  • All other request headers arrive as the client sent them.

A framework that builds absolute URLs or checks the origin of a request should trust X-Forwarded-Host and X-Forwarded-Proto from loopback. Because Host is the public name, a dev server that only accepts localhost as host needs that name on its allow list.

Timeouts

What Value What happens
Wait for the response to start 30 seconds The edge answers 504.
Upload in progress The 30 seconds start over with every piece of the request body that reaches the CLI A slow upload does not count against your service. An upload that stands still does.
Longest response 5 minutes on Free, 30 minutes on Pro and Team, from the arrival of the request A response that has not started by then is answered 504 (Hopwire: the response took longer than the plan of this tunnel allows); one that is still running is broken off. A tunnel with HOPWIRE_DEV_TOKEN has no plan and no such limit.
Open WebSocket No limit of its own Its open time counts towards the daily in-flight time of the plan. See below.
CLI connecting to the edge 15 seconds The edge at <url> cannot be reached (TIMEOUT); ...
CLI asking the control plane 15 seconds The control plane at <url> cannot be reached (TIMEOUT); ...
Connect token 300 seconds, renewed by the CLI at half time Nothing to do.

If the client goes away before the response is through, the edge tells the CLI and the request ends at your local service too.

If your handler needs longer than 30 seconds before it sends the first byte, send the status and headers early and stream the rest, or answer at once and do the work in the background. Webhook senders expect a quick answer anyway.

Limits per plan

Every public tunnel of a logged-in CLI runs under the plan of its organisation, and the edge enforces the plan's limits. A new organisation starts on Free. Plans are chosen and paid for on the Billing page of the control plane, which the owner and admins of the organisation can open.

Free Pro Team
Price including 19% German VAT €0 €9.52 a month, or €95.20 a year €46.41 a month, or €464.10 a year
Price net of VAT €0 €8 / $9 a month, or €80 / $90 a year €39 / $45 a month, or €390 / $450 a year
Members 1 1 Up to 5
Public URLs 1 fixed random t- URL The fixed URL plus 5 reserved names The fixed URL plus 25 reserved names
Tunnels online at once 1 3 15
Requests 2,000 a day 20,000 a day. Beyond that you are served up to 30,000 and get an email, then 429 100,000 a day, served up to 150,000
Data 200 MB a day (provisional) At least 500 MB a day, working ceiling 2 GB a day (provisional) At least 2.5 GB a day, ceiling 10 GB a day (provisional)
In-flight time (the sum of request durations) 20 minutes a day 5 hours a day 25 hours a day
Longest single response 5 minutes 30 minutes 30 minutes
Idle disconnect After 24 hours without a request None None
Browser warning page Yes No No
Basic Auth Included Included Included

For consumers the price is the total including VAT; businesses pay the net price plus any VAT that applies, and USD prices apply outside the euro area plus any tax there. The pricing page and the terms on hopwire.to are binding. Organisations created during the beta can get Pro yearly at a founding price of €76.16 a year including VAT (€64 / $72 net); see the pricing page for its conditions. Team is one organisation whose members share the plan; its limits are five times Pro, pooled.

How limits behave:

  • Limits belong to the organisation, not to a machine or a member: your personal organisation, or a team's. Requests, data and in-flight time are counted across all public tunnels of the organisation, on every machine, per UTC day.
  • At a limit the URL answers 429 until 00:00 UTC, with a one-sentence body that names the limit, for example This tunnel's organisation has used the daily request limit of its plan; requests are answered again from 00:00 UTC., and a Retry-After header with the seconds until then. Then the counters start again. A request answered this way does not count.
  • Never overage. Nothing is billed for traffic, no plan is upgraded by itself, and no charge is made that you did not choose.
  • In-flight time counts how long requests are being answered. An open WebSocket counts for as long as it is open. When the in-flight time of the day is used up, open WebSockets are closed with code 1008 and the reason Hopwire: the daily in-flight time of the plan is used up.
  • Tunnels online: a tunnel that connects when all the plan's tunnels are online is refused with 429. The CLI prints the edge's sentence (Your organisation already has 1 of 1 tunnels online, ...), does not retry and exits with code 1. A tunnel that reconnects keeps its place.
  • Idle disconnect on Free: after 24 hours without a public request the edge closes the tunnel. A request in flight or an open WebSocket counts as use. The CLI exits with code 1 and The edge closed the tunnel for <name> after 24 hours without a request, as the plan of your organisation does; start Hopwire again to reconnect it. Starting it again brings back the same fixed URL.
  • In the terminal: when a public tunnel connects, a Usage line under Public URL shows the plan and what the organisation used today, as the edge counted it at that moment. When the edge reports that a daily limit was reached, the CLI prints one line, for example Limit Daily request limit of the plan reached; public requests are answered 429 until 00:00 UTC. There is no hopwire usage command.
  • Limit emails go to the owner and the admins of the organisation at 80% and at 100% of a daily limit, once per limit and level per day. Requests are measured against the published limit (20,000 on Pro), data against the ceiling. The Usage page of the control plane shows where the organisation stands today and the last 30 days. Both use the numbers the control plane fetches from the edge every 5 minutes, so they can lag behind the edge by that much.
  • The warning page on Free is shown on HTML page loads from a browser, until the visitor continues; a cookie then keeps it away for 7 days on that browser. The edge removes this cookie before the request reaches your service. Webhooks, API calls and curl never see the page.
  • A plan change reaches the edge with the next renewal of the connect token, at most 150 seconds later.
  • The counters at the edge hold numbers per organisation and day. They never hold paths, headers or bodies. The edge hands each tunnel its share in small parts, so the numbers can run slightly ahead of what was actually used.
  • Private mode is never counted and has no limits. A tunnel with HOPWIRE_DEV_TOKEN on a local edge has no plan either.

On top of the plan, every public tunnel carries at most 10 open WebSocket connections (next section) and 100 requests in flight at once.

WebSocket passthrough

A public URL carries WebSocket connections to the local service. There is nothing to switch on.

sh
$ hopwire http 3000 --public --subdomain demo-api
# in another terminal, with any WebSocket client
$ wscat -c wss://demo-api.hwr.sh/socket

How it works:

  • A GET with Upgrade: websocket is passed to the local service like a request. If the service answers 101, the client is upgraded and messages flow both ways until one side closes. If the service answers anything else, the client gets that response as it is.
  • Path, query, Host, Origin, cookies, X-Forwarded-Host and X-Forwarded-Proto reach the service with the upgrade.
  • The subprotocols the client offers are passed on, and the one the service chooses goes back to the client.
  • Text and binary messages are passed on unchanged. Close codes and reasons travel from end to end.
  • Extensions such as per-message compression are not passed through. Each hop does its own handshake.
  • Headers the service sets next to its 101, such as Set-Cookie, reach the client.
  • The upgrade shows up in the inspector as an exchange with status 101. Messages are not recorded, so there is nothing to replay.

Limits:

Limit Value What happens beyond it
Open connections per tunnel 10 A further upgrade is answered 429. The open ones keep working.
Size of one message 1 MiB The connection is closed with code 1009 and the reason Hopwire: the message is too large.
Data waiting for a slow receiver, per connection 4 MiB The connection is closed with code 1013 and the reason Hopwire: the local side does not keep up or Hopwire: the client does not keep up.
Answer to the upgrade 30 seconds 504, as for a request.
Lifetime of an open connection No limit

When the tunnel goes away under an open connection (the CLI stopped, its connection to the edge was lost, or another tunnel replaced it), both ends are closed with code 1001 and the reason Hopwire: tunnel connection lost. Connections do not survive a reconnect of the CLI. Clients have to connect again, which every WebSocket client that is meant for production already does.

The 10 connections count per tunnel, not per client. On a URL without Basic Auth, anyone who knows the URL can hold them. Ordinary requests are not affected by that.

Error answers

Answers that come from Hopwire and not from your service are plain text. The ones the edge writes carry Cache-Control: no-store. Every 502 and 504 of Hopwire starts with Hopwire:, so you can tell it from a 502 your own service sent.

Status Body Meaning What to do
401 Authentication required The service has Basic Auth and the request carried no or wrong credentials. The header WWW-Authenticate: Basic realm="Hopwire" comes with it. Send the user and password of auth.basic, for example curl -u user:password. For a webhook sender, set them in its Basic Auth settings.
404 Not found The host name is not a tunnel address: the part before the public domain is not a well-formed subdomain. Check the URL for typos.
429 This tunnel already has 10 WebSocket connections open, which is the most it carries at once A WebSocket upgrade beyond the limit per tunnel. Close connections you no longer need, or wait for one to close. Requests are not affected.
429 This tunnel's organisation has used the daily request limit of its plan; requests are answered again from 00:00 UTC. (or daily data limit, daily in-flight time) The organisation reached a daily limit of its plan. Wait until 00:00 UTC (Retry-After says how long), or move to a plan with higher limits. Nothing is billed.
501 Upgrade requests other than for a WebSocket are not supported An Upgrade request for another protocol. Only WebSocket upgrades pass through.
502 Hopwire: tunnel offline No CLI is connected for this subdomain. Start the tunnel: hopwire http <port> --public. Check that the URL is the one the CLI printed.
502 Hopwire: tunnel connection lost The CLI's connection to the edge went away while the request waited: the CLI was stopped, lost its network, or was replaced by another tunnel on the same subdomain. Look at the terminal of the tunnel. It reconnects by itself after a lost connection. Send the request again.
502 Hopwire: the local service did not answer (ECONNREFUSED) The tunnel is up, but nothing answers on the local port. The code in brackets says why. Start the local service, and check that the port given to hopwire http is its port. This exchange is in the inspector.
502 Hopwire: the local service closed the connection while the request body was being sent (<code>); if it answered before that, the answer was lost The service hung up during an upload. Check the upload limits of the service.
502 Hopwire: the WebSocket handshake with the local service failed (...) The local service did not complete a WebSocket handshake. Check that the path is a WebSocket endpoint of the service.
502 Hopwire: the request could not be forwarded The CLI could not carry the request through. Send it again. If it stays, restart the tunnel.
502 Hopwire: the local side sent a malformed response The edge got a response it cannot pass on, for example a status below 200. Check what the service answers. If CLI and edge are different versions, update the CLI.
504 Hopwire: timeout, the local side did not answer in time The local service did not start its response within 30 seconds. Make the handler answer faster, or send the headers early and stream the rest. A breakpoint in a debugger causes this too.
504 Hopwire: the response took longer than the plan of this tunnel allows The response did not finish within the longest response of the plan (5 minutes on Free, 30 on Pro and Team). Make the response shorter, or move to a plan with a longer limit.

Two things that look like errors and are not:

  • A response whose body breaks off in the middle: the tunnel or the local service went away after the response had started. The status was already sent, so no error status can follow.
  • A sender that reports a failed delivery although your handler ran: it gave up before the answer arrived. The inspector shows what your service answered and how long it took.

When the tunnel stops by itself

A public tunnel that can no longer serve its subdomain says why on stderr and exits with code 1:

Message What to do
Another tunnel connected for the subdomain <name> and replaced this one; stop one of the two or use another subdomain. A second tunnel started on the same name, here or on another machine.
The control plane at <url> does not accept the API token (401): it is unknown or was revoked; create a new one there and run hopwire login again. The token was revoked while the tunnel ran. Create a new one and log in again.
Your organisation at <url> has not reserved the subdomain <name> (403); ... The name was released while the tunnel ran. Reserve it again.
The control plane at <url> no longer issues connect tokens for <name> (403); it is not the fixed URL of your organisation any more, so start the tunnel again. The control plane no longer issues tokens for this fixed URL. Start the tunnel again.
This name is still your organisation's, but its current plan has no room for it, so it is offline. ... (name_not_in_plan) The plan changed while the tunnel ran and no longer has room for this name.
Your organisation is suspended, so it cannot open public tunnels. ... (organisation_suspended) The organisation was suspended while the tunnel ran.
The edge closed the tunnel for <name> after 24 hours without a request, as the plan of your organisation does; start Hopwire again to reconnect it. Free plan only. Start the tunnel again; the URL stays the same.

A control plane that cannot be reached for a moment does not stop a tunnel. The CLI asks again while the current connect token is still valid.

Running the edge on your own machine

The edge runs locally with wrangler dev, without an account. This is for development on Hopwire itself and for trying public mode offline.

sh
# in a checkout of the repository
$ cp apps/edge/.dev.vars.example apps/edge/.dev.vars   # then replace the placeholder dev token
$ npm run dev --workspace @hopwire/edge                 # listens on 127.0.0.1:8787
sh
$ export HOPWIRE_EDGE_URL=ws://127.0.0.1:8787
$ export HOPWIRE_DEV_TOKEN=<the HOPWIRE_DEV_TOKEN of .dev.vars>
$ hopwire http 3000 --public --subdomain demo-api
text
Public URL   http://127.0.0.1:8787/demo-api
  • With HOPWIRE_DEV_TOKEN set, the CLI does not use your account and does not contact a control plane. Any name that fits the rules for --subdomain works, reserved or not. Without it the CLI makes up a random t- name.
  • A local edge has no wildcard DNS, so the tunnel is reached under a path: http://127.0.0.1:8787/<subdomain>/.... The first path segment names the tunnel and is not forwarded. As an alternative, send the header Hopwire-Subdomain: <subdomain> to http://127.0.0.1:8787/.
  • X-Forwarded-Proto is http here.
  • The dev token only works on an edge that runs in dev mode, and only for a CLI that connects through localhost or 127.0.0.1. A deployed edge refuses it.

With hopwire up, leave controlPlane.url out of hopwire.yaml and set HOPWIRE_DEV_TOKEN to get the same.