The OutRay client and tunnel server communicate over a WebSocket connection using a JSON-based message protocol. Every message is a JSON object with aDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/outray-tunnel/outray/llms.txt
Use this file to discover all available pages before exploring further.
type field that identifies the message kind.
Messages are serialized and deserialized using encodeMessage and decodeMessage from @outray/core.
Client → server messages
These messages are sent from the OutRay client to the tunnel server.open_tunnel
Sent immediately after the WebSocket connection is opened. Requests a new tunnel and provides authentication and routing information.
Always
"open_tunnel".Org-scoped authentication token. Required for custom subdomains and authenticated tunnels.
Requested subdomain (HTTP tunnels only). Omit for a randomly generated URL.
Custom fully-qualified domain name (HTTP tunnels only). Must be pre-configured in the dashboard.
Tunnel protocol:
"http", "tcp", or "udp". Defaults to "http" if omitted.Requested public port (TCP/UDP tunnels only). The server assigns a different port if this one is unavailable.
HTTP Basic Auth password (HTTP tunnels only). When set, the server requires authentication before forwarding requests.
When
true, the server forcefully reassigns the requested subdomain even if another client currently holds it. The client sets this automatically when reconnecting after a clean disconnect.response
Sent by the client in reply to a request message. Contains the HTTP response from the local service.
The request ID from the originating
request message. Used to match responses to requests.HTTP status code returned by the local service (e.g.
200, 404, 502).HTTP response headers as key/value pairs. Header values may be strings or arrays of strings.
Response body, base64-encoded. Omitted for responses with no body.
tcp_data (client → server)
Sends a chunk of TCP data from the local service back to the remote client.
Identifies the TCP connection this data belongs to.
Raw TCP bytes, base64-encoded.
tcp_close (client → server)
Signals that the client has closed its end of a TCP connection.
udp_response
Sends a UDP response datagram back to the remote sender.
Correlates the response with the originating
udp_data message.IP address of the remote UDP sender to reply to.
Port of the remote UDP sender to reply to.
UDP response payload, base64-encoded.
ws_upgrade_response
Confirms or rejects a WebSocket upgrade request from the server.
Matches the
wsConnectionId from the originating ws_upgrade message.true if the client successfully connected to the local WebSocket service.Error description when
success is false.ws_frame (client → server)
Relays a WebSocket frame from the local service back to the remote client.
ws_close (client → server)
Signals that the local WebSocket connection has closed.
Server → client messages
These messages are sent from the tunnel server to the OutRay client.tunnel_opened
Sent by the server once the tunnel is established. Contains the public URL (HTTP) or port number (TCP/UDP) assigned to the connection.
The public URL assigned to the tunnel. For HTTP tunnels this is an HTTPS URL such as
https://abc123.tunnel.outray.app. For TCP/UDP tunnels this is a placeholder URL; use port for the actual public port.The active tunnel protocol.
The assigned public port for TCP/UDP tunnels.
request
Forwards an HTTP request from an internet visitor to the client for local proxying.
Unique ID for this request. Must be echoed back in the corresponding
response message.HTTP method, e.g.
"GET", "POST".Request path and query string, e.g.
"/api/users?page=1".HTTP request headers forwarded from the visitor.
Request body, base64-encoded. Omitted for requests with no body.
tcp_connection
Notifies the client that a new remote TCP client has connected to the public port.
Unique identifier for this TCP connection. Used to correlate subsequent
tcp_data and tcp_close messages.tcp_data (server → client)
Delivers a chunk of data received from the remote TCP client.
tcp_close (server → client)
Signals that the remote TCP client has closed the connection.
udp_data
Delivers a UDP datagram received from an internet sender.
Unique identifier for this datagram. Echo it back in the
udp_response message.IP address of the remote UDP sender.
Port of the remote UDP sender.
UDP payload, base64-encoded.
error
Sent by the server when a request cannot be fulfilled. Fatal errors (AUTH_FAILED, LIMIT_EXCEEDED) cause the client to stop reconnecting.
Machine-readable error code. See error codes below.
Human-readable description of the error.
ws_upgrade
Sent when an internet visitor upgrades an HTTP connection to WebSocket. The client must connect to the local WebSocket service and reply with ws_upgrade_response.
Unique ID for this WebSocket connection. Used to correlate all subsequent
ws_frame and ws_close messages.The WebSocket upgrade path, e.g.
"/socket.io/".HTTP headers from the upgrade request.
Requested WebSocket sub-protocol, if any.
ws_frame (server → client)
Relays a WebSocket frame from the internet visitor to the client, which forwards it to the local service.
ws_close (server → client)
Signals that the internet visitor has closed the WebSocket connection.
Message type summary
| Message | Direction | Protocol | Description |
|---|---|---|---|
open_tunnel | Client → Server | All | Open a new tunnel. |
tunnel_opened | Server → Client | All | Tunnel established; provides public URL or port. |
request | Server → Client | HTTP | Forward an HTTP request to the local service. |
response | Client → Server | HTTP | Return the HTTP response to the server. |
tcp_connection | Server → Client | TCP | A new remote TCP client connected. |
tcp_data | Both | TCP | Relay a chunk of TCP data. |
tcp_close | Both | TCP | Close a TCP connection. |
udp_data | Server → Client | UDP | A UDP datagram from a remote sender. |
udp_response | Client → Server | UDP | A UDP response datagram. |
ws_upgrade | Server → Client | HTTP | Visitor is upgrading to WebSocket. |
ws_upgrade_response | Client → Server | HTTP | Confirm or reject the WebSocket upgrade. |
ws_frame | Both | HTTP | Relay a WebSocket frame. |
ws_close | Both | HTTP | Close a WebSocket connection. |
error | Server → Client | All | An error occurred. |
Error codes
Error codes are defined inpackages/core/src/types.ts and exported as ErrorCodes.
| Code | Fatal | Description |
|---|---|---|
SUBDOMAIN_IN_USE | No | The requested subdomain is currently held by another connection. The client automatically retries with forceTakeover: true. |
AUTH_FAILED | Yes | The provided API key is invalid or expired. The client stops reconnecting; the user must re-authenticate. |
LIMIT_EXCEEDED | Yes | The organization has reached its concurrent tunnel limit. The client stops reconnecting. |
INVALID_SUBDOMAIN | No | The requested subdomain contains characters that are not allowed. |
CUSTOM_DOMAIN_NOT_CONFIGURED | No | The requested custom domain has not been configured in the OutRay dashboard. |
Fatal errors (
AUTH_FAILED, LIMIT_EXCEEDED) cause OutrayClient to call stop() internally, preventing further reconnect attempts. All other errors allow the client to reconnect.