Unable to connect Kite connect API web sockets

xameeramir
This is my code here being implemented in React Typescript project:
    const ws = new WebSocket(`wss://ws.kite.trade?api_key=XXXXXX&access_token=XXXXXXXXXXX&uid=${(new Date().getTime().toString())}`);

ws.binaryType = 'arraybuffer';
ws.onopen = function (evt) {
// Subscribe to quotes for INFY (408065) and TATAMOTORS (884737)
const message = { "a": "subscribe", "v": [408065, 884737] };
ws.send(JSON.stringify(message));
};

ws.onerror = function (evt) {
console.log('Error', evt)
};

ws.onmessage = (e) => {
var server_message = e.data;
console.log(server_message);
}
I'm trying to connect as shown in the code but getting this error:

WebSocket connection to 'wss://ws.kite.trade/?api_key=XXXXXXXXXXX&access_token=XXXXXXXXXXXXX&uid=1610190561060' failed: Unknown reason

Any help, please?
Tagged:
  • sujith
    One can't display our data on third party websites.
  • sujith
    You can speak to compliance for more information at kiteconnect(at)zerodha.com
Sign In or Register to comment.