Getting encoded message from web socket in javascript
-
Followed the below steps to create and subscribe to a channel.
- Creating websocket for wss://wsfeeds.angelbroking.com/NestHtml5Mobile/socket/stream by passing the CLIENT_CODE and FEED_TOKEN as query params.
let socket = new WebSocket("wss://wsfeeds.angelbroking.com/NestHtml5Mobile/socket/stream"+"?CLIENT_CODE=" + CLIENT_CODE + "&FEED_TOKEN=" + FEED_TOKEN);
- sending request for task "cn"
var _req = '{"task":"cn","channel":"","token":"' + FEED_TOKEN + '","user": "' + CLIENT_CODE + '","acctid":"' + CLIENT_CODE + '"}'; socket.send(_req);
- Sending the request for task market watch "mw" and channel "mcx_fo|231091"
var strwatchlistscrips = "mcx_fo|231091"; var _req = '{"task":"mw","channel":"' + strwatchlistscrips + '","token":"' + FEED_TOKEN + '","user": "' + CLIENT_CODE + '","acctid":"' + CLIENT_CODE + '"}'; socket.send(_req);
- listening on-message
socket.onmessage = function (event) { console.log(new Date(),'-[ message ]', event.data) };
console output:
-
Hi @sammy kindly go through the decode logic from the SDK.
-
HI @sammy We have noted your issue we will update you on this you can also follow below link to use web socket in java script.
https://github.com/angelbroking-github/smartapi-javascript