I'm trying to use websockify to allow javascript executed in a browser to talk to my hand-written server. When using the latest versions of Chrome and Firefox, I get the following error message from websockify: Client must support 'binary' or 'base64' protocol
After looking at the code, I've determined that websockify delivers this message and closes the socket whenever both of these protocols fail to appear under the Sec-Websocket-Protocol header received from the client. When I look at the raw data transmitted by Chrome it doesn't even send this header. Is this a problem with Chrome or websockify, or am I failing to provide some information when opening the websocket in my javascript? Or is there some other explanation?
You need to provide the protocol list as part of the object constructor:
var ws = new WebSocket(uri, ['binary', 'base64']);
If you use the websock.js library included with websockify then it will handle this for you. However, note that websock.js does not provide the standard WebSocket API but rather a streaming oriented API. Even if you use a raw WebSocket connection to websockify, note that you will still need to do message reconstruction because normal TCP does not have a concept of messages so the messages chunking from onmessage will be essentially "arbitrary".
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With