Skip to content

feat: add --ws-url flag and wss:// scheme support#15

Merged
byshing merged 1 commit into
BitMEX:masterfrom
jhob:feat/ws-url-flag
Jun 12, 2026
Merged

feat: add --ws-url flag and wss:// scheme support#15
byshing merged 1 commit into
BitMEX:masterfrom
jhob:feat/ws-url-flag

Conversation

@jhob

@jhob jhob commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Adds a --ws-url global flag to override the WebSocket endpoint, mirroring the existing --api-url / BITMEX_API_URL pattern
  • Fixes BITMEX_WS_URL env var being silently ignored — it was read in main.rs but never wired through to the Ws command dispatch
  • Extends resolve_url_override to accept wss:// and ws:// schemes; ws:// is subject to the same localhost-only restriction as http://

Usage

# CLI flag
bitmex --ws-url wss://ws.example.com/realtime ws position

# Env var (was previously a no-op)
export BITMEX_WS_URL=wss://ws.example.com/realtime
bitmex ws position

Priority: --ws-url flag > BITMEX_WS_URL env var > testnet/mainnet default.

Test plan

  • bitmex --ws-url wss://<host>/realtime ws <public-topic> connects to the specified host
  • BITMEX_WS_URL=wss://<host>/realtime bitmex ws <topic> is now respected
  • --ws-url with an http:// or ws:// non-localhost URL is rejected without BITMEX_DANGER_ALLOW_ANY_URL_HOST=1
  • Omitting --ws-url still falls back to mainnet/testnet defaults as before

🤖 Generated with Claude Code

Adds a --ws-url CLI flag (and BITMEX_WS_URL env var, which previously
existed but was silently ignored) to override the WebSocket endpoint,
mirroring the existing --api-url / BITMEX_API_URL pattern.

- Add --ws-url global flag to Cli struct
- Wire cli.ws_url through resolve() so BITMEX_WS_URL env var is
  also respected (previously the env var was read but never used)
- Use ctx.ws_url in the Ws command dispatch, falling back to
  mainnet/testnet defaults when unset
- Extend resolve_url_override to accept wss:// and ws:// schemes;
  ws:// is subject to the same localhost-only restriction as http://

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
@jhob jhob force-pushed the feat/ws-url-flag branch from c5a9a20 to 147ec2b Compare June 12, 2026 07:55
@byshing byshing merged commit 560afba into BitMEX:master Jun 12, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants