WebSocket connection error: server rejected WebSocket connection: HTTP 400
Reconnecting Again…
Watchlist changed. Reconnecting the feed…
Disconnected from WebSocket feed.
WebSocket connection error: server rejected WebSocket connection: HTTP 400
E:\Kumar\Dhan Algo Series\Testing>py “How to use updated codebase.py”
Codebase Version 2.8 : Solved - Strike Selection Issue
-----Logged into Dhan-----
reading existing file all_instrument 2026-01-29.csv
Got the instrument file
Exception at calling ltp as {‘status’: ‘failure’, ‘remarks’: {‘error_code’: None, ‘error_type’: None, ‘error_message’: None}, ‘data’: {‘data’: {‘806’: ‘Data APIs not Subscribed’}, ‘status’: ‘failed’}}
Do get LTP do we need data APIs sibscrtion can’t we get with Trading API token
‘806’: ‘Data APIs not Subscribed’
Code as follows:
import pdb
import time
import datetime
import traceback
from Dhan_Tradehull import Tradehull
import pandas as pd
from pprint import pprint
import talib
client_code = “1100430497”
token_id = “eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJpc3MiOiJkaGFuIiwicGFydG5lcklkIjoiIiwiZXhwIjoxNzY5NzU0OTE5LCJpYXQiOjE3Njk2Njg1MTksInRva2VuQ29uc3VtZXJUeXBlIjoiU0VMRiIsIndlYmhvb2tVcmwiOiIiLCJkaGFuQ2xpZW50SWQiOiIxMTAwNDMwNDk3In0.BgPTw58GX5zwqHXLuVeiMzhXaqEF7T61Av-QxorG1WPW6_0b3-hDNA1riWlBt83a36pXpVCOURk0XSLcS3KvFg”
tsl = Tradehull(client_code,token_id)
all_ltp_data = tsl.get_ltp_data(names = [“ACC”, “CIPLA”])
Hey @V_Srinivas ,
We want to inform you that to connect to the WebSocket, you must first subscribe to the Data API.
To do this, please log in to web.dhan.co → click on your profile → select Get Trading API and Data API → choose Data API and complete the subscription.
Also @Tradehull_Imran if anything else you may assist here further.