diff --git a/README.md b/README.md index 3e2afb7..e39039a 100644 --- a/README.md +++ b/README.md @@ -424,7 +424,7 @@ const coin = await ws.nameToCoin('HYPE/USDC'); await ws.subscribe({ type: 'trades', coin }); ``` -`connectionTimeout` bounds connection attempts and defaults to 1,000 ms. Pings run every 10,000 ms with a 1,000 ms pong deadline. Set `pingInterval: 0` to disable pings or `pongTimeout: 0` to disable that deadline. Reconnect delays start at 500 ms and double up to 10,000 ms; configure `reconnectTimeout` and `maxReconnectTimeout` to change them, or set `autoReconnect: false` to disable recovery. Timeouts must be finite and positive; ping and reconnect controls also accept zero. Use `off()` or `removeAllListeners()` to remove listeners, and `close()` or `closeAll()` to close connections and clear their cached topics. +`connectionTimeout` bounds connection attempts and defaults to 10,000 ms. Pings run every 10,000 ms with a 1,000 ms pong deadline. Set `pingInterval: 0` to disable pings or `pongTimeout: 0` to disable that deadline. Reconnect delays start at 500 ms and double up to 10,000 ms; configure `reconnectTimeout` and `maxReconnectTimeout` to change them, or set `autoReconnect: false` to disable recovery. Timeouts must be finite and positive; ping and reconnect controls also accept zero. Use `off()` or `removeAllListeners()` to remove listeners, and `close()` or `closeAll()` to close connections and clear their cached topics. Closing immediately rejects pending requests and clears timers. For an active socket, the `close` event confirms that the connection has actually closed. After an unexpected disconnect, reconnection restores subscriptions, but interrupted WS API requests are rejected rather than replayed. diff --git a/docs/HYPERLIQUID_SDK_QUICKSTART_GUIDE.md b/docs/HYPERLIQUID_SDK_QUICKSTART_GUIDE.md index 456e8d0..aa92bf5 100644 --- a/docs/HYPERLIQUID_SDK_QUICKSTART_GUIDE.md +++ b/docs/HYPERLIQUID_SDK_QUICKSTART_GUIDE.md @@ -587,7 +587,7 @@ Some channels send an initial snapshot before later updates. `l2Book` sends a cu `subscribe()` and `unsubscribe()` accept one topic or an array of topics. Equivalent topics are deduplicated by value. Listeners are independent of subscriptions: use `off('message', listener)` to remove a listener and `unsubscribe(topic)` to stop a stream. Call `client.closeAll()` when the application needs to close its WebSocket connections. -`connectionTimeout` defaults to 1,000 ms. Heartbeats use a 10,000 ms ping interval and a 1,000 ms pong deadline. Increase `connectionTimeout` or `pongTimeout` for a higher-latency connection. Reconnect delays start at 500 ms and double up to 10,000 ms. +`connectionTimeout` defaults to 10,000 ms. Heartbeats use a 10,000 ms ping interval and a 1,000 ms pong deadline. Increase `connectionTimeout` or `pongTimeout` for a higher-latency connection. Reconnect delays start at 500 ms and double up to 10,000 ms. #### Subscribe to a Spot market diff --git a/llms.txt b/llms.txt index dc06c08..5be9c87 100644 --- a/llms.txt +++ b/llms.txt @@ -1444,7 +1444,7 @@ export interface WebsocketClientOptions { /** Reconnect automatically after an unexpected disconnect. Default: true. */ autoReconnect?: boolean; baseUrl?: string; - /** Maximum time to open a connection, in milliseconds. Default: 1,000. */ + /** Maximum time to open a connection, in milliseconds. Default: 10,000. */ connectionTimeout?: number; /** Maximum reconnect delay in milliseconds. Default: 10,000. Zero means no delay. */ maxReconnectTimeout?: number; @@ -1464,7 +1464,7 @@ export interface WebsocketClientOptions { ⋮---- /** Reconnect automatically after an unexpected disconnect. Default: true. */ ⋮---- -/** Maximum time to open a connection, in milliseconds. Default: 1,000. */ +/** Maximum time to open a connection, in milliseconds. Default: 10,000. */ ⋮---- /** Maximum reconnect delay in milliseconds. Default: 10,000. Zero means no delay. */ ⋮---- @@ -2162,7 +2162,7 @@ Some channels send an initial snapshot before later updates. `l2Book` sends a cu `subscribe()` and `unsubscribe()` accept one topic or an array of topics. Equivalent topics are deduplicated by value. Listeners are independent of subscriptions: use `off('message', listener)` to remove a listener and `unsubscribe(topic)` to stop a stream. Call `client.closeAll()` when the application needs to close its WebSocket connections. -`connectionTimeout` defaults to 1,000 ms. Heartbeats use a 10,000 ms ping interval and a 1,000 ms pong deadline. Increase `connectionTimeout` or `pongTimeout` for a higher-latency connection. Reconnect delays start at 500 ms and double up to 10,000 ms. +`connectionTimeout` defaults to 10,000 ms. Heartbeats use a 10,000 ms ping interval and a 1,000 ms pong deadline. Increase `connectionTimeout` or `pongTimeout` for a higher-latency connection. Reconnect delays start at 500 ms and double up to 10,000 ms. #### Subscribe to a Spot market @@ -6771,7 +6771,7 @@ const coin = await ws.nameToCoin('HYPE/USDC'); await ws.subscribe({ type: 'trades', coin }); ``` -`connectionTimeout` bounds connection attempts and defaults to 1,000 ms. Pings run every 10,000 ms with a 1,000 ms pong deadline. Set `pingInterval: 0` to disable pings or `pongTimeout: 0` to disable that deadline. Reconnect delays start at 500 ms and double up to 10,000 ms; configure `reconnectTimeout` and `maxReconnectTimeout` to change them, or set `autoReconnect: false` to disable recovery. Timeouts must be finite and positive; ping and reconnect controls also accept zero. Use `off()` or `removeAllListeners()` to remove listeners, and `close()` or `closeAll()` to close connections and clear their cached topics. +`connectionTimeout` bounds connection attempts and defaults to 10,000 ms. Pings run every 10,000 ms with a 1,000 ms pong deadline. Set `pingInterval: 0` to disable pings or `pongTimeout: 0` to disable that deadline. Reconnect delays start at 500 ms and double up to 10,000 ms; configure `reconnectTimeout` and `maxReconnectTimeout` to change them, or set `autoReconnect: false` to disable recovery. Timeouts must be finite and positive; ping and reconnect controls also accept zero. Use `off()` or `removeAllListeners()` to remove listeners, and `close()` or `closeAll()` to close connections and clear their cached topics. Closing immediately rejects pending requests and clears timers. For an active socket, the `close` event confirms that the connection has actually closed. After an unexpected disconnect, reconnection restores subscriptions, but interrupted WS API requests are rejected rather than replayed. diff --git a/src/lib/BaseWSClient.ts b/src/lib/BaseWSClient.ts index 8039cd3..29ba77a 100644 --- a/src/lib/BaseWSClient.ts +++ b/src/lib/BaseWSClient.ts @@ -91,7 +91,7 @@ export abstract class BaseWebsocketClient< autoReconnect: options.autoReconnect !== false, connectionTimeout: finiteTimeout( options.connectionTimeout, - 1_000, + 10_000, 'connectionTimeout', ), maxReconnectTimeout: finiteTimeout( diff --git a/src/types/websockets/ws-general.ts b/src/types/websockets/ws-general.ts index 221f3ee..bfcd13c 100644 --- a/src/types/websockets/ws-general.ts +++ b/src/types/websockets/ws-general.ts @@ -15,7 +15,7 @@ export interface WebsocketClientOptions { /** Reconnect automatically after an unexpected disconnect. Default: true. */ autoReconnect?: boolean; baseUrl?: string; - /** Maximum time to open a connection, in milliseconds. Default: 1,000. */ + /** Maximum time to open a connection, in milliseconds. Default: 10,000. */ connectionTimeout?: number; /** Maximum reconnect delay in milliseconds. Default: 10,000. Zero means no delay. */ maxReconnectTimeout?: number;