[Libwebsockets] question on websockets protocol name - required?

Michael Haberler mail17 at mah.priv.at
Tue Jan 7 23:08:30 CET 2014

to answer my own question:

Am 06.01.2014 um 22:19 schrieb Michael Haberler <andy.green at linaro.org>:

> Hi!
> so far - looking at examples and being a websocket noob - I was under the impression one had to have a protocols struct with a websocket protocol name, requiring the client to send a "Sec-WebSocket-Protocol: <protocolname>" header
> now I found this, which just gets away with a single http-only protocol entry:
> https://github.com/otcshare/automotive-message-broker/blob/master/plugins/websocketsourceplugin/websocketsource.cpp
> this would make it simpler for some clients which dont support a protocol name out of the box, like  https://pypi.python.org/pypi/websocket-client/ *)
> question - assume I used this:
> can I still serve http and websockets from a single callback? 

yes - sessions without a Sec-WebSocket-Protocol: header will be funneled through the protocol 0 handler (http)

using a protocol name on the client side will abort the session ('Req protocol <protocolname> not supported')

> or would that force the scheme to serve only websockets?


> thanks in advance,
> Michael
> *) it still does, just needs header=["Sec-WebSocket-Protocol: <protocolname>"] in the websocket.WebSocketApp() instantiation
> _______________________________________________
> Libwebsockets mailing list
> Libwebsockets at ml.libwebsockets.org
> http://ml.libwebsockets.org/mailman/listinfo/libwebsockets

More information about the Libwebsockets mailing list