MarketDataStreamerV3 Error in Connection

The Error Message:
Streamer Error: Error: Unexpected server response: 403
at ClientRequest. (E:\Real Scanner 22102025\Real Scanner Back End\node_modules\ws\lib\websocket.js:913:7)
at ClientRequest.emit (node:events:513:28)
at HTTPParser.parserOnIncomingClient [as onIncoming] (node:_http_client:701:27)
at HTTPParser.parserOnHeadersComplete (node:_http_common:119:17)
at TLSSocket.socketOnData (node:_http_client:542:22)
at TLSSocket.emit (node:events:513:28)
at addChunk (node:internal/streams/readable:324:12)
at readableAddChunk (node:internal/streams/readable:297:9)
at Readable.push (node:internal/streams/readable:234:10)
at TLSWrap.onStreamRead (node:internal/stream_base_commons:190:23)

Code:

const init = async () => {

let defaultClient = UpstoxClient.ApiClient.instance;

var OAUTH2 = defaultClient.authentications[ā€œOAUTH2ā€];

var scriptList = await getAutoTradingScripts();

OAUTH2.accessToken = await getAccessToken();

const streamer = new UpstoxClient.MarketDataStreamerV3();

streamer.connect();

streamer.autoReconnect(true, 10, 3);

streamer.on(ā€œopenā€, () => {

console.log(" Streamer Connected");

 streamer.subscribe(scriptList, "full");

});

}

why the error is coming.?

Hi @SRIKANTA_1078821,

Can you check the number of connections you have created for Market data v3 websocket, seems like you are getting forbidden message because of connection more than allowed number of websocket connections.

Refer for the allowed limits Market Data Feed V3 | Upstox Developer API

Thanks!

Then how to close existing streamer connection?

ok … problem solved

1 Like