Issue with 200 level data

@Shrutika_Poojari I was trying to subscribe for 200 level data streaming through websocket but after connection was established , i couldn’t recieve the messages : i have used the offical documentation with requestcode 23 but still dosn’t work PS D:\test\backend> python debug_dhanhq_connection.py
:magnifying_glass_tilted_left: Testing DhanHQ WebSocket connection…
INFO:auth:Environment variables loaded from .env file
INFO:auth:DhanHQ credentials loaded and validated successfully
:white_check_mark: Credentials loaded successfully
Client ID: 1103706176
Access Token: ********************…SYCMnrmGMQ
INFO:parser_config:Loaded parser configuration: {‘mode’: ‘corrected’, ‘enab
le_fallback’: True, ‘log_parser_selection’: True, ‘validation_enabled’: True, ‘performance_monitoring’: False} INFO:parser_config::wrench: DhanHQ Parser Configuration:
INFO:parser_config: Mode: corrected
INFO:parser_config: Fallback Enabled: True
INFO:parser_config: Validation Enabled: True
INFO:parser_config: Performance Monitoring: False
INFO:parser_config: Using default configuration (no environment variables
set) INFO:parser_factory::white_check_mark: Initialized corrected parser as primary
INFO:parser_factory::counterclockwise_arrows_button: Legacy parser available as fallback
INFO:parser_config::rocket: DhanHQ Market Depth Parser Startup:
INFO:parser_config: Selected Parser: corrected
INFO:parser_config: :white_check_mark: Using corrected 200-level parser (RequestCode 23,
12-byte header) INFO:parser_config: :bar_chart: Features: 200 bid/ask levels, comprehensive valida
tion, compliance monitoring INFO:parser_config: :counterclockwise_arrows_button: Fallback enabled: Will switch to legacy parser if
corrected parser fails INFO:parser_config: :magnifying_glass_tilted_left: Validation enabled: Comprehensive message validati
on active :link: Connecting to DhanHQ…
INFO:websocket_client:Connecting to DhanHQ WebSocket API…
INFO:websocket_client::white_check_mark: Connected to DhanHQ WebSocket API successfully
INFO:websocket_client::magnifying_glass_tilted_left: Started DhanHQ ping-pong compliance monitoring
INFO:websocket_client::clipboard: Official requirements: Server ping every 10s, client response within 40s :white_check_mark: Connected to DhanHQ successfully
:satellite_antenna: Subscribing to RELIANCE (1333) on NSE_EQ…
INFO:compliance_logger::satellite_antenna: Attempting subscription: 1333 on NSE_EQ (RequestC
ode: 23) (correlation_id: 8af7eeb5) INFO:compliance_logger::white_check_mark: Subscription OK: subscription_request: RequestCod
e 23 (success) (correlation_id: 8af7eeb5) INFO:websocket_client:Sent corrected subscription (RequestCode 23) for 1333
on NSE_EQ INFO:websocket_client::white_check_mark: Successfully subscribed to 1333 on NSE_EQ for 200-
level depth INFO:websocket_client::bar_chart: Note: Only one instrument can be subscribed per co
nnection (DhanHQ 200-level API restriction) INFO:compliance_logger::white_check_mark: Subscription OK: subscription_success: RequestCode 23 (success) (correlation_id: 8af7eeb5) :white_check_mark: Subscription successful
:hourglass_not_done: Waiting for market data (30 seconds)…

:chart_increasing: Connection Statistics:
Messages received: 0
Connection state: connected
Ping count: 0
Pong count: 0

:warning: No market data received
This could be because:

  • Markets are closed or low activity
  • Access token doesn’t have market data permissions
  • Instrument is not actively trading
    INFO:websocket_client:Disconnecting from DhanHQ WebSocket API…
    WARNING:websocket_client:WebSocket connection closed
    WARNING:websocket_client::counterclockwise_arrows_button: WebSocket disconnected - initiating reconnectio
    n… INFO:websocket_client::counterclockwise_arrows_button: Reconnection attempt 1/3 in 1 seconds…
    INFO:websocket_client::white_check_mark: Disconnected from DhanHQ WebSocket API
    :electric_plug: Disconnected from DhanHQ

Hey @Venkata_Krishnasai_A,

Please note that the 200-level depth Python sample isn’t officially provided by us. However, you can refer to our GitHub repository where we’ve shared the Python sample for the 20-level depth here: GitHub - dhan-oss/DhanHQ-py: The official Python client for communicating with the Dhan API..

You can find the required base URL for 200-level depth here: Full Market Depth - DhanHQ Ver 2.0 / API Document.

Please ensure you’re using the correct request structure as shown below:

{
  "RequestCode": 23,
  "ExchangeSegment": "NSE_EQ",
  "SecurityId": "1333"
}