Documentation 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.
OutrayClient accepts a single options object in its constructor. All fields except localPort are optional.
TypeScript interface
Verbatim frompackages/core/src/types.ts:
Connection options
The local port that OutRay forwards incoming traffic to. Must be an integer between 1 and 65535.
WebSocket URL of the OutRay tunnel server. Must use the
ws:// or wss:// scheme. Override this when connecting to a self-hosted OutRay server.API key used to authenticate with the OutRay server. Without a key the server issues an anonymous, unauthenticated tunnel with a randomly generated URL and no subdomain control.
Tunnel options
The tunnel protocol. One of
"http", "tcp", or "udp".Request a specific subdomain for the tunnel URL. Requires authentication. If the subdomain is taken when reconnecting, the client automatically attempts a takeover.
Use a fully-qualified custom domain instead of a generated subdomain URL. The domain must be set up in the OutRay dashboard and DNS must point to the OutRay server before traffic can be served.
Request a specific public port for TCP or UDP tunnels. If the port is unavailable the server assigns a different one.
Callbacks
onTunnelReady
url is the public HTTPS URL for HTTP tunnels. For TCP/UDP tunnels port contains the assigned public port number.
onError
code is one of the error codes when the error originates from the OutRay server, or undefined for network-level errors.
When
code is AUTH_FAILED or LIMIT_EXCEEDED the client stops reconnecting automatically. All other errors trigger a reconnect with exponential backoff.onClose
client.stop() is called or the server sends a "Tunnel stopped by user" close frame). Not called on error-induced disconnects — those trigger onError followed by onReconnecting.
onReconnecting
attempt is the 1-based attempt count. delay is the number of milliseconds the client will wait before opening a new WebSocket connection. The backoff is exponential, capped at 30 seconds: Math.min(2000 * 2^attempt, 30000).
onRequest
HTTP method of the request, for example
"GET" or "POST".Request path including query string, for example
"/api/users?page=1".HTTP status code returned by the local server. Set to
502 when the local server is unreachable.Round-trip time in milliseconds from receiving the request to sending the response.
Error message string when the local server returned an error or was unreachable.
undefined on successful requests.Client methods
Once constructed,OutrayClient exposes four methods:
| Method | Returns | Description |
|---|---|---|
start() | void | Open the WebSocket connection and begin tunneling. |
stop() | void | Close the connection, cancel any pending reconnects, and release resources. |
getUrl() | string | null | Return the currently assigned tunnel URL, or null if not yet connected. |
isConnected() | boolean | Return true if the WebSocket connection is open. |