Skip to content

ConnectSupervisedSubscriberOptions

Defined in: relay-sdks/ts/src/supervised-subscriber.ts:55

Options for connectSupervisedSubscriber: the subscriber connection options and the reconnection policy.

connectTimeoutMs?: number;

Defined in: relay-sdks/ts/src/connect-session.ts:87

Deadline for token resolution, transport connection, and protocol SETUP. Default 10 seconds, maximum 2147483647.

ConnectRelaySubscriberOptions.connectTimeoutMs


createTransport?: RelayTransportFactory;

Defined in: relay-sdks/ts/src/connect-session.ts:93

Create the transport. Defaults to the browser’s WebTransport; a runtime without it, or whose WebTransport cannot negotiate protocols, fails with TRANSPORT_UNAVAILABLE unless this is supplied.

ConnectRelaySubscriberOptions.createTransport


getToken?: () =>
| string
| RelayCredential
| Promise<
| string
| RelayCredential
| undefined>
| undefined;

Defined in: relay-sdks/ts/src/connect-session.ts:83

Resolve a connection token. Relay carries it in the endpoint’s jwt query parameter. An explicit jwt in the URL wins, and the provider is not called in that case. An empty jwt in the URL is a RangeError, raised before the provider or the transport is used. Return a RelayCredential to say when the token expires; for a bare token the connection reads the JWT’s exp claim, without verifying it. The provider runs once per connection: a live session keeps the token it connected with until the relay ends it at that expiry.

| string | RelayCredential | Promise< | string | RelayCredential | undefined> | undefined

ConnectRelaySubscriberOptions.getToken


reconnect?: SupervisionBackoff;

Defined in: relay-sdks/ts/src/supervised-subscriber.ts:57

Backoff between connection attempts. Default from 500 ms, doubling up to 10 s, with jitter.


requestTimeoutMs?: number;

Defined in: relay-sdks/ts/src/connect-session.ts:99

Deadline for an initial subscription response, not for silence on an accepted track. Default 10 seconds, maximum 2147483647.

ConnectRelaySubscriberOptions.requestTimeoutMs


rotateBeforeMs?: number;

Defined in: relay-sdks/ts/src/supervised-subscriber.ts:62

How long before the connection’s credential expires (RelaySubscriber.expiresAt) a replacement connection is opened, make-before-break. Default 60 seconds; never earlier than halfway through the time left.


signal?: AbortSignal;

Defined in: relay-sdks/ts/src/connect-session.ts:85

Aborting closes the connection, including after the connect call has resolved.

ConnectRelaySubscriberOptions.signal


url?: string;

Defined in: relay-sdks/ts/src/connect-session.ts:74

Relay’s HTTPS WebTransport endpoint, including any endpoint path. Left out, the connection dials DEFAULT_ENDPOINT rooted at the token’s root claim, read without verifying the token: the URL roomEndpoint builds from that root. getToken is then required, and a token that names no usable root is a TypeError or RangeError before the transport is used. Pass url for another relay, region or room.

ConnectRelaySubscriberOptions.url

onStatus?(status, error?): void;

Defined in: relay-sdks/ts/src/supervised-subscriber.ts:68

Called on every status change; error is what ended the previous connection or failed the last attempt. A throw stops the supervisor with that error: a pending connectSupervisedSubscriber rejects with it and closed resolves with it. A throw reporting closed is rethrown from the close() that caused it; closed resolves either way.

Parameter Type
status SupervisedStatus
error? unknown

void