feat: add --ws-url flag and wss:// scheme support#15
Merged
Conversation
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>
byshing
approved these changes
Jun 12, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
--ws-urlglobal flag to override the WebSocket endpoint, mirroring the existing--api-url/BITMEX_API_URLpatternBITMEX_WS_URLenv var being silently ignored — it was read inmain.rsbut never wired through to theWscommand dispatchresolve_url_overrideto acceptwss://andws://schemes;ws://is subject to the same localhost-only restriction ashttp://Usage
Priority:
--ws-urlflag >BITMEX_WS_URLenv var > testnet/mainnet default.Test plan
bitmex --ws-url wss://<host>/realtime ws <public-topic>connects to the specified hostBITMEX_WS_URL=wss://<host>/realtime bitmex ws <topic>is now respected--ws-urlwith anhttp://orws://non-localhost URL is rejected withoutBITMEX_DANGER_ALLOW_ANY_URL_HOST=1--ws-urlstill falls back to mainnet/testnet defaults as before🤖 Generated with Claude Code