Websocket error in nodejs


  • Hi,
    I am gertting this error below while trying to create websocket instance. pls help..

    PS C:\stk\smartapi-javascript-main> node app.js
    C:\stk\smartapi-javascript-main\lib\websocket2.0.js:80
    throw new Error(evt.message);
    ^

    Error: Unexpected server response: 401
    at WebSocket.ws.onerror (C:\stk\smartapi-javascript-main\lib\websocket2.0.js:80:14)
    at callListener (C:\stk\smartapi-javascript-main\node_modules\ws\lib\event-target.js:290:14)
    at WebSocket.onError (C:\stk\smartapi-javascript-main\node_modules\ws\lib\event-target.js:230:9)
    at WebSocket.emit (node:events:527:28)
    at emitErrorAndClose (C:\stk\smartapi-javascript-main\node_modules\ws\lib\websocket.js:1008:13)
    at processTicksAndRejections (node:internal/process/task_queues:83:21)