Hi,
I am trying to create websocket connection using java script but it gives this error. I used below url format to connect the server where I have replaced variables with actual value. I am able to get profile information using simple get profile api call but websocket connect doesn't work.
It says failed to connect and gives this error "Error observed : {"isTrusted":true}" Can anybody please help me here?
My client Id : P51757
let NEW_URL = "wss://smartapisocket.angelbroking.com/websocket?jwttoken=" + JWT_TOKEN + "&&clientcode=" + FEED_TOKEN + "&&clientcode=" +CLIENT_CODE+ "&&apikey=" +API_KEY + "&&feedType=" + FEED_TYPE
let websocketObj = new WebSocket(NEW_URL);
websocketObj.onopen = function() {
let strwatchlistscrips = "nse_cm|2885&nse_cm|1594&nse_cm|11536";
var _watchReq = '{"task":"mw","channel":"' + strwatchlistscrips + '","token":"' + FEED_TOKEN + '","user": "' + CLIENT_CODE + '","acctid":"' + CLIENT_CODE + '"}';
console.log('connection req : ' + _watchReq);
websocketObj. send(_watchReq);
console.log('socket opened.')
}
websocketObj.onerror = function(error) {
console.log('Error observed : ' + JSON.stringify(error));
};