nathan
nathan

Reputation: 81

I want to check "Sec-WebSocket-Accept" in client side

I'm making a C server of websocket :D actually one time I did connect successfully but after then, this onOpen is not triggering again...and tells me

Error during WebSocket handshake: Sec-WebSocket-Accept mismatch

so now I need to check what client HTML takes especially the Sec-WebSocket-Accept field

Is there a way I can check Sec-WebSocket-Accept field in javascript client side? What value should I check for this?

Upvotes: 1

Views: 1616

Answers (1)

oberstet
oberstet

Reputation: 22011

The Sec-WebSocket-Accept header expected to be sent by a WebSocket server during the initial opening handshake cannot be accessed from JavaScript (in browsers).

You can however look at the complete opening handshake i.e. in the developer console of Chrome, after the handshake has succeeded.

The value must be computed by the server based on the Sec-WebSocket-Key sent by the client (and a magic string). You can read the details in https://www.rfc-editor.org/rfc/rfc6455

Upvotes: 2

Related Questions