Create the first bridge#
A bridge joins one desktop connection and one mobile connection. This procedure
uses two websocat terminals to prove that the relay admits both roles and
forwards text unchanged.
Before you start#
- Start a local relay as described in Deploy.
- Install
websocator another interactive WebSocket client. - Open two terminals.
- Choose a session identifier containing only letters, digits,
.,_, or-. Use an unguessable value outside local testing.
Connect the desktop#
Open the first socket.
websocat ws://127.0.0.1:8080/Send the desktop hello as the first text frame.
{"type":"desktop_hello","session_id":"first-session"}Confirm that the relay answers:
{"type":"session_ready","session_id":"first-session"}
Send the hello within five seconds of opening the socket. A binary hello or a late hello is not admitted.
Connect the mobile#
Open the second socket against the same relay.
Send a mobile hello with the same session identifier.
{"type":"mobile_hello","session_id":"first-session"}Confirm that the mobile receives
session_readyfollowed by:{"type":"peer_connected"}
The desktop also receives peer_connected when the mobile joins. A mobile
hello cannot create a bridge; the desktop must establish it first.
Send a frame#
Type a text value into either terminal:
{"hello":"world"}
The other terminal receives the same text. The relay does not parse or wrap
bridge payloads. The exact one-field envelope {"type":"ping"} is reserved as
a keepalive on a bridge and is not forwarded to the peer. See
Protocol for how the same envelope behaves on the other
session kinds.
Verify#
The bridge is working when:
- each hello receives
session_ready; - both sides observe
peer_connected; - a normal text frame crosses unchanged in each direction; and
- closing either terminal causes the survivor to receive
{"type":"peer_disconnected"}.
If it does not work#
| Result | Cause |
|---|---|
session not found |
The mobile connected before the desktop created the bridge, or the desktop disconnected. |
invalid session ID |
The identifier is empty, too long, or contains an unsupported character. |
The socket closes without session_ready |
The hello was late, binary, or not a supported JSON hello. |
| A frame does not cross | The second peer is absent, the frame is binary, or the frame is the reserved keepalive. |
Next#
- Bridge sessions — reconnect and lifecycle behaviour.
- Protocol — all supported envelopes.