@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
Testing DhanHQ WebSocket connection…
INFO:auth:Environment variables loaded from .env file
INFO:auth:DhanHQ credentials loaded and validated successfully
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:
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:
Initialized corrected parser as primary
INFO:parser_factory:
Legacy parser available as fallback
INFO:parser_config:
DhanHQ Market Depth Parser Startup:
INFO:parser_config: Selected Parser: corrected
INFO:parser_config:
Using corrected 200-level parser (RequestCode 23,
12-byte header) INFO:parser_config:
Features: 200 bid/ask levels, comprehensive valida
tion, compliance monitoring INFO:parser_config:
Fallback enabled: Will switch to legacy parser if
corrected parser fails INFO:parser_config:
Validation enabled: Comprehensive message validati
on active
Connecting to DhanHQ…
INFO:websocket_client:Connecting to DhanHQ WebSocket API…
INFO:websocket_client:
Connected to DhanHQ WebSocket API successfully
INFO:websocket_client:
Started DhanHQ ping-pong compliance monitoring
INFO:websocket_client:
Official requirements: Server ping every 10s, client response within 40s
Connected to DhanHQ successfully
Subscribing to RELIANCE (1333) on NSE_EQ…
INFO:compliance_logger:
Attempting subscription: 1333 on NSE_EQ (RequestC
ode: 23) (correlation_id: 8af7eeb5) INFO:compliance_logger:
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:
Successfully subscribed to 1333 on NSE_EQ for 200-
level depth INFO:websocket_client:
Note: Only one instrument can be subscribed per co
nnection (DhanHQ 200-level API restriction) INFO:compliance_logger:
Subscription OK: subscription_success: RequestCode 23 (success) (correlation_id: 8af7eeb5)
Subscription successful
Waiting for market data (30 seconds)…
Connection Statistics:
Messages received: 0
Connection state: connected
Ping count: 0
Pong count: 0
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:
WebSocket disconnected - initiating reconnectio
n… INFO:websocket_client:
Reconnection attempt 1/3 in 1 seconds…
INFO:websocket_client:
Disconnected from DhanHQ WebSocket API
Disconnected from DhanHQ