Search code examples
androidwebsocketautobahn

How to set specific Sec-WebSocket-Key in Client's WebSocket opening handshake message using autobahn android library?


I want to set custom/specific Sec-WebSocket-Key in Client's Websocket opening handshake message. I am using Autobahn Android library for creating websocket in android.

I could connect to local Autobahn Python server example using provided Android example app code for Websocket. But I am unable to connect custom server which needs specific Sec-WebSocket-Key for opening a connection(I think it's not mandatory to have a particular Sec-WebSocket-Key for a server but still..)

so is there any way to set this specific key in Client's websocket opening handshake message using any of the autobahn android api method?


Solution

  • The WebSocket spec (RFC6455) requires a compliant client to generate a random key on each and every connection.

    A server that mandates a specific key isn't spec compliant. There are no hooks in AutobahnAndroid to set a specific key (and we won't add such things). Please fix your server or use a compliant one.

    You can find the code for generating news keys here.