Interface: WebSocketOptions
Defined in: api/rust-fetch.d.ts:685
Properties
allowAbsoluteUrls?
optionalallowAbsoluteUrls?:boolean
Defined in: api/rust-fetch.d.ts:709
Overrides the client's allowAbsoluteUrls
allowPrivateNetwork?
optionalallowPrivateNetwork?:boolean
Defined in: api/rust-fetch.d.ts:716
Node.js: overrides the client's allowPrivateNetwork. With false, an IP address that is private or reserved throws a NetworkError from websocket(), and a host name is checked on every connection, reconnections included (a blocked one fails the attempt with "Blocked: …"). Can't be combined with dispatcher, and fails while another undici global dispatcher is installed. Browsers have their own rules.
dispatcher?
optionaldispatcher?:object
Defined in: api/rust-fetch.d.ts:700
Node.js only: an undici dispatcher for the connection, e.g. new ProxyAgent('http://proxy:3128') from the undici package to connect through a proxy. Node's WebSocket doesn't use the client's proxy option.
headers?
optionalheaders?:HeadersLike
Defined in: api/rust-fetch.d.ts:695
Handshake headers, merged over the client's headers. Node.js only: browsers don't allow WebSocket headers, so there this rejects with an InvalidInputError (client headers are skipped).
idleTimeoutMs?
optionalidleTimeoutMs?:number
Defined in: api/rust-fetch.d.ts:687
Maximum silence after open/between received messages. 0 disables; defaults to the client's idleTimeoutMs. No heartbeat messages are sent.
maxQueuedBytes?
optionalmaxQueuedBytes?:number
Defined in: api/rust-fetch.d.ts:727
The most bytes (UTF-8 for text, byteLength or size otherwise) send() queues while the connection isn't open yet. A message that would go over throws a NetworkError whose maxQueuedBytes is the limit, and isn't queued. Once open, messages go to the runtime's socket: watch bufferedAmount there. Default: no limit
maxQueuedMessages?
optionalmaxQueuedMessages?:number
Defined in: api/rust-fetch.d.ts:721
The most messages send() queues while the connection isn't open yet (connecting or reconnecting). One more throws a NetworkError whose maxQueuedMessages is the limit, and isn't queued. Default: no limit
messageType?
optionalmessageType?:"auto"|"json"
Defined in: api/rust-fetch.d.ts:731
auto (default): text messages as strings, binary ones as Uint8Array. json: text messages parsed as JSON
onClose?
optionalonClose?: (info) =>void
Defined in: api/rust-fetch.d.ts:740
Called once, when the connection is closed for good
Parameters
info
Returns
void
onError?
optionalonError?: (error) =>void
Defined in: api/rust-fetch.d.ts:736
Called on every failure: a failed or timed-out attempt, an unexpected drop, a message that isn't JSON
Parameters
error
Returns
void
onMessage?
optionalonMessage?: (data) =>void
Defined in: api/rust-fetch.d.ts:734
Parameters
data
any
Returns
void
onOpen?
optionalonOpen?: () =>void
Defined in: api/rust-fetch.d.ts:733
Called each time a connection opens, including after reconnecting
Returns
void
onReconnect?
optionalonReconnect?: (info) =>void
Defined in: api/rust-fetch.d.ts:738
Called before waiting to reconnect
Parameters
info
Returns
void
params?
optionalparams?:QueryParams
Defined in: api/rust-fetch.d.ts:690
protocols?
optionalprotocols?:string|string[]
Defined in: api/rust-fetch.d.ts:689
Subprotocols to offer
reconnect?
optionalreconnect?:number|boolean|ReconnectOptions
Defined in: api/rust-fetch.d.ts:707
Reconnect when a connection fails or drops unexpectedly (close codes 1001, 1006, 1011-1014): true for the defaults, a maximum number of attempts in a row, or options. Default: off
signal?
optionalsignal?:AbortSignal
Defined in: api/rust-fetch.d.ts:729
Closes the connection and stops reconnecting when aborted
timeoutMs?
optionaltimeoutMs?:number
Defined in: api/rust-fetch.d.ts:702
Time allowed for each connection attempt, in ms. 0 disables it. Default: the client's timeoutMs