View Source Hyperliquid.WebSocket.Connection (hyperliquid v0.2.2)
WebSocket connection handler with automatic reconnection.
Manages a single WebSocket connection to Hyperliquid, handling:
- Connection establishment and authentication
- Subscription management
- Message routing
- Automatic reconnection with exponential backoff
Usage
Typically managed by Hyperliquid.WebSocket.Manager, but can be used directly:
{:ok, pid} = Connection.start_link(
key: "l2Book:BTC:5",
manager: manager_pid,
url: "wss://api.hyperliquid.xyz/ws"
)
# Subscribe
Connection.subscribe(pid, %{type: "l2Book", coin: "BTC", nSigFigs: 5}, "sub_123")
# Unsubscribe
Connection.unsubscribe(pid, "sub_123")
Summary
Functions
Returns a specification to start this module under a supervisor.
Lookup connection by key.
Start a WebSocket connection.
Get connection status.
Subscribe to a channel on this connection.
Unsubscribe from a channel.
Functions
Returns a specification to start this module under a supervisor.
See Supervisor.
Lookup connection by key.
Start a WebSocket connection.
Options
:key- Required. Connection identifier:manager- Required. Manager PID for message routing:url- WebSocket URL (default: wss://api.hyperliquid.xyz/ws)
Get connection status.
Subscribe to a channel on this connection.
Unsubscribe from a channel.