Skip to content

Standardise WS config shape for proxy support #14

Open

Description

@tiagosiebler

Minor changes needed to align it with how our other SDKs support proxies for WebSockets.

Proxy configuration in @siebly/hyperliquid-api is more involved than in the Binance, Bybit and Kraken SDKs. There are two separate issues:

  1. The other SDKs support wsOptions: { agent }. Hyperliquid currently accepts webSocketConstructor and calls it with the URL alone, so consumers need a wrapper around ws and a TypeScript compatibility assertion.

  2. WebsocketClient passes requestOptions to its internal metadata REST client, but the default keep-alive setup replaces a supplied HTTPS agent. This affects explicit metadata helpers such as nameToCoin(), resolveAsset() and refreshAssetMetadata(), not ordinary stream subscriptions.

High level notes:

  • Support wsOptions: { agent } for Node.js WebSocket connections, including reconnects and WebsocketAPIClient.
  • Preserve an explicitly supplied REST agent instead of replacing it with the default keep-alive agent.
  • Keep existing webSocketConstructor usage working, define how it interacts with the new options, and preserve browser compatibility.
  • Simplify the proxy examples while keeping WebSocket and REST routing clear.

Verify that the agent is used on connection and reconnection, that the metadata REST client preserves a custom agent, and that existing custom-constructor and browser usage still works.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions