Problem in conencting to websocket client getting 405 bad request error

ashu3889
Hi All, i am getting 405 bad request error while conencting to websocket from Javascript client.I am using like this:

var ticker = new KiteTicker({api_key: API_SECRET,access_token: API_TOKEN});

ticker.connect();
ticker.on("tick", this.onTick(ticker));
ticker.on("connect", this.onConnect(ticker));

And getting 405 bad request error.

I have read that i have to add authorization header.

Please help me with a sample code to connect to websocket from client.
Thanks
Tagged:
  • rakeshr
    @ashu3889
    Instead of KiteTicket, it should be WebSocket.You can have look to this document.
  • ashu3889
    Can you please send me a sample code for websocket connect? i have trouble connecting it
  • rakeshr
    @ashu3889
    It's given in above link.
    // Javascript example.
    var ws = new WebSocket("wss://ws.kite.trade?api_key=xxx&access_token=xxxx");
    // Subscribe to quotes for INFY (408065) and TATAMOTORS (884737)
    var message = {"a": "subscribe", "v": [408065, 884737]};
    ws.send(JSON.stringify(message))
  • ashu3889
    Thanks for help... While connecting to websocket from client i am getting 101 Switching Protocols and request is not completed. Please help
  • ashu3889
    Hi Rakesh, after connecting to websocket i am getting data as istrusted: true.. please tell me how will i get the data of quote. thanks for help
Sign In or Register to comment.