KO-9 / node-trading212

NodeJS Trading212 Unofficial API
19 stars 3 forks source link

error 403 on connection since 1st April 2022 #9

Closed ghost closed 1 year ago

ghost commented 2 years ago

Anyone knows what the issue is?

C:\Users\xxx\Trading212-delete>node app.js node:events:504 throw er; // Unhandled 'error' event ^

Error: Unexpected server response: 403 at ClientRequest. (C:\Users\xxx\Trading212-delete\node_modules\trading212\node_modules\ws\lib\websocket.js:767:7) at ClientRequest.emit (node:events:526:28) at HTTPParser.parserOnIncomingClient [as onIncoming] (node:_http_client:618:27) at HTTPParser.parserOnHeadersComplete (node:_http_common:128:17) at TLSSocket.socketOnData (node:_http_client:482:22) at TLSSocket.emit (node:events:526:28) at addChunk (node:internal/streams/readable:315:12) at readableAddChunk (node:internal/streams/readable:289:9) at TLSSocket.Readable.push (node:internal/streams/readable:228:10) at TLSWrap.onStreamRead (node:internal/stream_base_commons:190:23) Emitted 'error' event on WebSocket instance at: at abortHandshake (C:\Users\xxx\Trading212-delete\node_modules\trading212\node_modules\ws\lib\websocket.js:935:15) at ClientRequest. (C:\Users\xxx\Trading212-delete\node_modules\trading212\node_modules\ws\lib\websocket.js:767:7) [... lines matching original stack trace ...] at TLSSocket.Readable.push (node:internal/streams/readable:228:10)

ghost commented 2 years ago

I got it. The fix is to insert the following line in index.js line 42 "User-Agent": "Mozilla"

Happy trading again :)

KO-9 commented 1 year ago

Thanks, I've updated the package now to include this