<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Node JS WebSocketV2]]></title><description><![CDATA[<p dir="auto">while using fetchdata function from WebSocketV2</p>
<p dir="auto">code :<br />
web_socket.fetchData({<br />
correlationID: "abcde12345",<br />
action: 1,<br />
params: {<br />
mode: 1,<br />
tokenList: [<br />
{<br />
exchangeType: 1,<br />
tokens: ["10626", "5290"],<br />
},<br />
],<br />
},<br />
});</p>
<p dir="auto">gives an error</p>
<p dir="auto">error :<br />
⨯ node_modules\smartapi-javascript\lib\websocket2.0.js (137:0) @ WebSocketV2.fetchData<br />
⨯ Error: Invalid Mode value passed<br />
at page (./src/app/page.jsx:63:16)<br />
null<br />
Error: Invalid Mode value passed<br />
at WebSocketV2.fetchData (webpack-internal:///(rsc)/./node_modules/smartapi-javascript/lib/websocket2.0.js:137:11)<br />
at eval (webpack-internal:///(rsc)/./node_modules/smartapi-javascript/lib/websocket2.0.js:52:14)<br />
at Array.map (&lt;anonymous&gt;)<br />
at WebSocket.onOpen (webpack-internal:///(rsc)/./node_modules/smartapi-javascript/lib/websocket2.0.js:51:20)<br />
at callListener (webpack-internal:///(rsc)/./node_modules/ws/lib/event-target.js:290:14)<br />
at WebSocket.onOpen (webpack-internal:///(rsc)/./node_modules/ws/lib/event-target.js:237:9)<br />
at WebSocket.emit (node:events:518:28)<br />
at WebSocket.setSocket (webpack-internal:///(rsc)/./node_modules/ws/lib/websocket.js:244:10)<br />
at ClientRequest.eval (webpack-internal:///(rsc)/./node_modules/ws/lib/websocket.js:1009:15)<br />
at ClientRequest.emit (node:events:518:28)<br />
at TLSSocket.socketOnData (node:_http_client:575:11)<br />
at TLSSocket.emit (node:events:518:28)<br />
at addChunk (node:internal/streams/readable:559:12)<br />
at readableAddChunkPushByteMode (node:internal/streams/readable:510:3)<br />
at Readable.push (node:internal/streams/readable:390:5)<br />
at TLSWrap.onStreamRead (node:internal/stream_base_commons:190:23)<br />
at TLSWrap.callbackTrampoline (node:internal/async_hooks:130:17)</p>
<p dir="auto">I think this error is due to the structure of passing parameter in fetchData function.</p>
]]></description><link>https://smartapi.angelone.in/smartapi/forum/topic/4418/node-js-websocketv2</link><generator>RSS for Node</generator><lastBuildDate>Fri, 13 Nov 2026 18:58:49 GMT</lastBuildDate><atom:link href="https://smartapi.angelone.in/smartapi/forum/topic/4418.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 10 Mar 2024 13:45:11 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Node JS WebSocketV2 on Mon, 11 Mar 2024 17:28:32 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://smartapi.angelone.in/smartapi/forum/uid/22768">@Moderator_2</a><br />
"next": "14.1.3",<br />
I am using next js instead of node js to connect with WebSocketV2 directly from fronend.</p>
<p dir="auto">It got connected and worked very fine with all the function defined in WebSocketV2 leaving WebSocketV2.fetchData function in smartapi-javascript\lib\websocket2.0.js which is upload in your github repo <a href="https://github.com/angel-one/smartapi-javascript/blob/main/lib/websocket2.0.js" target="_blank" rel="noopener noreferrer nofollow ugc">https://github.com/angel-one/smartapi-javascript/blob/main/lib/websocket2.0.js</a>.</p>
<p dir="auto">In documentation it said to pass parameter like :<br />
{<br />
"correlationID": "abcde12345",<br />
"action": 1,<br />
"params": {<br />
"mode": 1,<br />
"tokenList": [<br />
{<br />
"exchangeType": 1,<br />
"tokens": [<br />
"10626",<br />
"5290"<br />
]<br />
},<br />
{<br />
"exchangeType": 5,<br />
"tokens": [<br />
"234230",<br />
"234235",<br />
"234219"<br />
]<br />
}<br />
]<br />
}<br />
}</p>
<p dir="auto">but while retriving in WebSocketV2.fetchData function which is in line number 127 of <a href="https://github.com/angel-one/smartapi-javascript/blob/main/lib/websocket2.0.js" target="_blank" rel="noopener noreferrer nofollow ugc">https://github.com/angel-one/smartapi-javascript/blob/main/lib/websocket2.0.js</a> file is like</p>
<p dir="auto">const { correlationID, action, mode, exchangeType, tokens } = json_req;</p>
<p dir="auto">but i am passing data in different structure , so as to retrive the data i pass it has to be like :</p>
<p dir="auto">const { correlationID, action, params : {mode, tokenList :{exchangeType, tokens} }} = json_req;</p>
<p dir="auto">I request please provide the solution as soon as possible.<br />
Thank you</p>
]]></description><link>https://smartapi.angelone.in/smartapi/forum/post/15829</link><guid isPermaLink="true">https://smartapi.angelone.in/smartapi/forum/post/15829</guid><dc:creator><![CDATA[greatworld]]></dc:creator><pubDate>Mon, 11 Mar 2024 17:28:32 GMT</pubDate></item><item><title><![CDATA[Reply to Node JS WebSocketV2 on Mon, 11 Mar 2024 16:00:53 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://smartapi.angelone.in/smartapi/forum/uid/22768">@Moderator_2</a></p>
<p dir="auto">"next": "14.1.3",</p>
<p dir="auto">I am using next js instead of node js to conncect directly with WebSocketV2 from frontend and it's working fine for other functions define in WebSocketV2.</p>
<p dir="auto">The only problem I see is in fetchdata function defined in smartapi-javascript\lib\websocket2.0.js file which is upload in your github <a href="https://github.com/angel-one/smartapi-javascript/blob/main/lib/websocket2.0.js" target="_blank" rel="noopener noreferrer nofollow ugc">https://github.com/angel-one/smartapi-javascript/blob/main/lib/websocket2.0.js</a></p>
<p dir="auto">The structure of sending the data to websocket2.0 is describe as<br />
{<br />
"correlationID": "abcde12345",<br />
"action": 1,<br />
"params": {<br />
"mode": 1,<br />
"tokenList": [<br />
{<br />
"exchangeType": 1,<br />
"tokens": [<br />
"10626",<br />
"5290"<br />
]<br />
},<br />
{<br />
"exchangeType": 5,<br />
"tokens": [<br />
"234230",<br />
"234235",<br />
"234219"<br />
]<br />
}<br />
]<br />
}<br />
}<br />
whereas at receiving end of fetchData function which is<br />
const { correlationID, action, mode, exchangeType, tokens } = json_req;<br />
couldn't fetch request data because it is not in fromat of<br />
{ correlationID, action, mode, exchangeType, tokens }</p>
<p dir="auto">It should be<br />
const {<br />
correlationID,<br />
action,<br />
params :<br />
{<br />
mode,<br />
tokenList :{<br />
exchangeType, tokens<br />
}<br />
}<br />
} = json_req;</p>
<p dir="auto">Please solve the issue as soon as possible.<br />
Thank you</p>
]]></description><link>https://smartapi.angelone.in/smartapi/forum/post/15832</link><guid isPermaLink="true">https://smartapi.angelone.in/smartapi/forum/post/15832</guid><dc:creator><![CDATA[greatworld]]></dc:creator><pubDate>Mon, 11 Mar 2024 16:00:53 GMT</pubDate></item><item><title><![CDATA[Reply to Node JS WebSocketV2 on Mon, 11 Mar 2024 14:29:17 GMT]]></title><description><![CDATA[<p dir="auto">hi <a class="plugin-mentions-user plugin-mentions-a" href="https://smartapi.angelone.in/smartapi/forum/uid/23803">@greatworld</a></p>
<p dir="auto">Please share the SDK version consumed at your end.</p>
<p dir="auto">Regards,<br />
SmartAPI team</p>
]]></description><link>https://smartapi.angelone.in/smartapi/forum/post/15828</link><guid isPermaLink="true">https://smartapi.angelone.in/smartapi/forum/post/15828</guid><dc:creator><![CDATA[Moderator_2]]></dc:creator><pubDate>Mon, 11 Mar 2024 14:29:17 GMT</pubDate></item></channel></rss>