Skip to content

API reference / @chanx-js/client / core / SocketOptions

Interface: SocketOptions ​

Defined in: packages/client/src/core/socket.ts:29

Extended by ​

Properties ​

closeDelay? ​

ts
optional closeDelay?: number;

Defined in: packages/client/src/core/socket.ts:59

Grace period before a socket with no remaining consumers is actually closed. React's StrictMode unmounts and immediately remounts in development, which would otherwise tear down and rebuild the connection on every mount.


heartbeat? ​

ts
optional heartbeat?: false | HeartbeatOptions;

Defined in: packages/client/src/core/socket.ts:50

Ping on an interval and reconnect if nothing comes back. Off unless enabled: chanx consumers only answer ping when they declare a handler for it, and one that does not replies with an error frame every interval. connect() turns it on for channels whose schema declares ping/pong.


maxQueuedFrames? ​

ts
optional maxQueuedFrames?: number;

Defined in: packages/client/src/core/socket.ts:52

Cap on frames buffered while the socket is not yet open.


onReconnectStop? ​

ts
optional onReconnectStop?: (attempts) => void;

Defined in: packages/client/src/core/socket.ts:43

Parameters ​

ParameterType
attemptsnumber

Returns ​

void


protocols? ​

ts
optional protocols?: string | string[];

Defined in: packages/client/src/core/socket.ts:30


queryParams? ​

ts
optional queryParams?: Record<string, string | number>;

Defined in: packages/client/src/core/socket.ts:31


reconnectAttempts? ​

ts
optional reconnectAttempts?: number;

Defined in: packages/client/src/core/socket.ts:39


reconnectInterval? ​

ts
optional reconnectInterval?: number | ((attempt) => number);

Defined in: packages/client/src/core/socket.ts:41

Fixed delay, or a function of the attempt number for backoff.


retryOnError? ​

ts
optional retryOnError?: boolean;

Defined in: packages/client/src/core/socket.ts:42


share? ​

ts
optional share?: boolean;

Defined in: packages/client/src/core/socket.ts:37

Share one socket per resolved URL. connect() defaults it to true for channels that carry topics and false otherwise: topic frames are routed per consumer, but on a plain channel every consumer of a shared socket sees every reply.


shouldReconnect? ​

ts
optional shouldReconnect?: (event) => boolean;

Defined in: packages/client/src/core/socket.ts:38

Parameters ​

ParameterType
event{ code?: number; reason?: string; }
event.code?number
event.reason?string

Returns ​

boolean


socketFactory? ​

ts
optional socketFactory?: SocketFactory;

Defined in: packages/client/src/core/socket.ts:53

MIT licensed