Websockify error "The client must support the protocol" binary "or" base64 "

I am trying to use websockify so that javascript executed in a browser speaks to my mail server. When using the latest versions of Chrome and Firefox, I get the following error message from websockify: The client must support the "binary" or "base64" protocol

After looking at the code, I decided that websockify delivers this message and closes the socket when both of these protocols are not displayed in the Sec-Websocket-Protocol header received from the client. When I look at the raw data transmitted by Chrome, it does not even send this header. Is this a problem with Chrome or websockify, or I can not provide some information when opening websocket in my javascript? Or is there another explanation?

+6
source share
1 answer

You need to provide a list of protocols as part of the object constructor:

var ws = new WebSocket(uri, ['binary', 'base64']); 

If you use the websock.js library included with websockify, it will handle this for you. However, note that websock.js does not provide a standard WebSocket API, but rather a streaming oriented API. Even if you are using a raw WebSocket connection with websockify, note that you will still need to perform message recovery, because regular TCP does not have a message concept, so messages related to onmessage will be essentially "arbitrary".

+8
source

All Articles