[Libwebsockets] Server returning multiple protocols in upgrade response

Andy Green andy at warmcat.com
Sat Nov 26 02:57:06 CET 2016


On Fri, 2016-11-25 at 19:31 -0500, Alan Conway wrote:
> I am seeing that an lws server does not choose a single protocol from
> the list proposed by the client, but echos back the same list that
> the
> client sent. I can reproduce this with the test-server and test-
> client, 
> I go the same result on v2.0.3 and v2.1.0. 
> 
> Here's the conversation as seen by wireshark:
> 
> GET // HTTP/1.1
> Pragma: no-cache
> Cache-Control: no-cache
> Host: localhost
> Origin: http://localhost
> Upgrade: websocket
> Connection: Upgrade
> Sec-WebSocket-Key: fa5CMy5EXE6fcPsq2v8aiA==
> Sec-WebSocket-Protocol: dumb-increment-protocol,fake-nonexistant-
> protocol
> Sec-WebSocket-Version: 13
> 
> HTTP/1.1 101 Switching Protocols
> Upgrade: WebSocket
> Connection: Upgrade
> Sec-WebSocket-Accept: CcN27PWx89CoAu/TzPDZJuHX7vQ=
> Sec-WebSocket-Protocol: dumb-increment-protocol,fake-nonexistant-
> protocol
> 
> Am I missing something? If not I'll raise an issue on github.

It seems like it's broken as you say.

Although on both server and client it parses the protocols correctly at
the comma boundary and correctly selects the protocol using that name,
when it makes the handshake it just sends back the list that came in,
which is clearly wrong.  The lws client deals with it and selects the
right protocol so it has been hidden.

Can you try this which I pushed on master

https://github.com/warmcat/libwebsockets/commit/be9478480e2303f488b29c1ff802bd4fda6a2786

if it doesn't make any new trouble I'll add it to the stable branches.

-Andy

> Thanks
> Alan.
> _______________________________________________
> Libwebsockets mailing list
> Libwebsockets at ml.libwebsockets.org
> http://libwebsockets.org/mailman/listinfo/libwebsockets



More information about the Libwebsockets mailing list