diff --git a/v4-client-py-v2/documentation/network_setup.md b/v4-client-py-v2/documentation/network_setup.md index 59081c15..509b4ca5 100644 --- a/v4-client-py-v2/documentation/network_setup.md +++ b/v4-client-py-v2/documentation/network_setup.md @@ -14,13 +14,13 @@ To connect to the mainnet, use the `make_mainnet` function: from dydx_v4_client.network import make_mainnet NETWORK = make_mainnet( - node_url="dydx-ops-grpc.kingnodes.com:443", # No 'https://' prefix - rest_indexer="https://indexer.v4.dydx.exchange", - websocket_indexer="wss://indexer.v4.dydx.exchange/v4/ws" + node_url="NODE_URL", # No 'https://' prefix + rest_indexer="REST_INDEXER", + websocket_indexer="WEBSOCKET_INDEXER" ) ``` -Note the above are just an example of the mainnet endpoints. Always use the most recent endpoints from our [network resources documentation](https://docs.dydx.exchange/infrastructure_providers-network/resources#networks-repositories). +> Note the above are just an example of the mainnet endpoints. Always use the most recent endpoints from our [network resources documentation](https://docs.dydx.exchange/infrastructure_providers-network/resources#indexer-endpoints). ⚠️ **Important:** When specifying `node_url`, do not include the `https://` prefix. This is a common mistake that can cause connection issues. diff --git a/v4-client-py-v2/dydx_v4_client/network.py b/v4-client-py-v2/dydx_v4_client/network.py index e0ae9266..316e2025 100644 --- a/v4-client-py-v2/dydx_v4_client/network.py +++ b/v4-client-py-v2/dydx_v4_client/network.py @@ -1,9 +1,12 @@ +import logging from dataclasses import dataclass from functools import partial import grpc from grpc import insecure_channel +logger = logging.getLogger(__name__) + secure_channel = partial( grpc.secure_channel, credentials=grpc.ssl_channel_credentials() ) @@ -27,6 +30,12 @@ class Network: def make_config( make_channel, make_node, rest_indexer: str, websocket_indexer: str, node_url: str ): + if node_url.startswith("http://") or node_url.startswith("https://"): + logger.warning( + "Node URL should not contain http(s)://. Stripping the prefix. In the future, consider providing the URL without the http(s) prefix." + ) + node_url = node_url.split("://", 1)[1] + return Network( rest_indexer, websocket_indexer,