Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[websocket]WebSocket handshake Unexpected response code 403 #62

Open
cherishman2005 opened this issue Oct 7, 2023 · 2 comments
Open

Comments

@cherishman2005
Copy link
Owner

  [Symbol(kError)]: Error: Unexpected server response: 403
      at ClientRequest.<anonymous> (/data/services/webrtc/collider_tools/rtc_server/node_modules/ws/lib/websocket.js:896:7)
      at ClientRequest.emit (events.js:400:28)
      at HTTPParser.parserOnIncomingClient [as onIncoming] (_http_client.js:647:27)
      at HTTPParser.parserOnHeadersComplete (_http_common.js:127:17)
      at TLSSocket.socketOnData (_http_client.js:515:22)
      at TLSSocket.emit (events.js:400:28)
      at addChunk (internal/streams/readable.js:293:12)
      at readableAddChunk (internal/streams/readable.js:267:9)
      at TLSSocket.Readable.push (internal/streams/readable.js:206:10)
      at TLSWrap.onStreamRead (internal/stream_base_commons.js:188:23),
  [Symbol(kMessage)]: 'Unexpected server response: 403'
@cherishman2005
Copy link
Owner Author

@cherishman2005
Copy link
Owner Author

cherishman2005 commented Oct 7, 2023

Can you try header like this and check

var ws = new WebSocket('wss://apiv2.unificationengine.com/v2/ws/start', {
    origin: 'https://apiv2.unificationengine.com',
    headers: { Authorization: 'base64 auth' }
});
You can create base64 auth like this in nodejs

var auth = "Basic " + new Buffer(USER_ACCESS_KEY + ":" + USER_ACCESS_SECRET).toString("base64");

resolve it:

var ws = new WebSocket('wss://***.com/v2/ws/start', {
    origin: 'https://***.com',
});

https://stackoverflow.com/questions/40027826/error-403-when-trying-to-connect-to-websocket-api

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant