Skip to main content
Version: 11.x

Interface: WebSocketClientOptions

Defined in: packages/client/dist/links/wsLink/wsClient/options.d.ts:2

Extends

  • UrlOptionsWithConnectionParams

Properties

connectionParams?

optional connectionParams: CallbackOrValue<null | Dict<string>>

Defined in: packages/client/dist/links/internals/urlWithConnectionParams.d.ts:21

Connection params that are available in createContext()

  • For wsLink/wsClient, these are sent as the first message
  • For httpSubscriptionLink, these are serialized as part of the URL under the connectionParams query

Inherited from

UrlOptionsWithConnectionParams.connectionParams


keepAlive?

optional keepAlive: object

Defined in: packages/client/dist/links/wsLink/wsClient/options.d.ts:44

Send ping messages to the server and kill the connection if no pong message is returned

enabled

enabled: boolean

Default
ts
false
ts
false

intervalMs?

optional intervalMs: number

Send a ping message every this many milliseconds

Default
ts
5_000
ts
5_000

pongTimeoutMs?

optional pongTimeoutMs: number

Close the WebSocket after this many milliseconds if the server does not respond

Default
ts
1_000
ts
1_000

lazy?

optional lazy: object

Defined in: packages/client/dist/links/wsLink/wsClient/options.d.ts:29

Lazy mode will close the WebSocket automatically after a period of inactivity (no messages sent or received and no pending requests)

closeMs

closeMs: number

Close the WebSocket after this many milliseconds

Default
ts
0
ts
0

enabled

enabled: boolean

Enable lazy mode

Default
ts
false
ts
false

onClose()?

optional onClose: (cause?) => void

Defined in: packages/client/dist/links/wsLink/wsClient/options.d.ts:23

Triggered when a WebSocket connection is closed

Parameters

ParameterType
cause?{ code: number; }
cause.code?number

Returns

void


onError()?

optional onError: (evt?) => void

Defined in: packages/client/dist/links/wsLink/wsClient/options.d.ts:19

Triggered when a WebSocket connection encounters an error

Parameters

ParameterType
evt?Event

Returns

void


onOpen()?

optional onOpen: () => void

Defined in: packages/client/dist/links/wsLink/wsClient/options.d.ts:15

Triggered when a WebSocket connection is established

Returns

void


retryDelayMs()?

optional retryDelayMs: (attemptIndex) => number

Defined in: packages/client/dist/links/wsLink/wsClient/options.d.ts:11

The number of milliseconds before a reconnect is attempted.

Parameters

ParameterType
attemptIndexnumber

Returns

number

Default

exponentialBackoff


url

url: CallbackOrValue<string>

Defined in: packages/client/dist/links/internals/urlWithConnectionParams.d.ts:15

The URL to connect to (can be a function that returns a URL)

Inherited from

UrlOptionsWithConnectionParams.url


WebSocket()?

optional WebSocket: (url, protocols?) => WebSocket

Defined in: packages/client/dist/links/wsLink/wsClient/options.d.ts:6

Ponyfill which WebSocket implementation to use

Parameters

ParameterType
urlstring | URL
protocols?string | string[]

Returns

WebSocket

CLOSED

readonly CLOSED: 3

CLOSING

readonly CLOSING: 2

CONNECTING

readonly CONNECTING: 0

OPEN

readonly OPEN: 1

prototype

prototype: WebSocket