If you’re using the
@lifi/perps-sdk, the PerpsWsClient handles all connection management, subscriptions, and data normalization automatically.Connection Discovery
The WebSocket URL for each provider is advertised via theGET /providers endpoint in the optional wsUrl field. Not all providers may support WebSocket — check for its presence before attempting to connect.
wsUrl. The URL points to the provider’s native WebSocket endpoint — message formats, available channels, and rate limits are provider-specific.
Reconnection
If the connection drops:- Wait with jittered exponential backoff — the first retry delay is drawn once per socket from
[500ms, 1500ms)(to de-synchronize reconnect storms), then grows by a factor of 1.3 each attempt, capped at 10s - Reconnect to the same
wsUrl - Re-send all active subscriptions
disconnected and stops retrying.
The SDK’s PerpsWsClient handles this automatically.