When the SWSS (Simple-WebSocket-Server) client connects to a server running libwebsockets:
- The connection gets set up, and data moves through
- The server fails to to call the appropriate callback for the specified protocol (
/sky/api/v0/controller-sky
in the example shown here)
This libwebsockets implementation is working, which I know because:
- The connection gets up, and data moves through
- The server calls the correct callback for the specified protocol (
front-panel-protocol
)
Captured the output of libwebsockets from a known working connection (see other files in this gist)
Dumped the TCP traffic for SWSS from a known working connection (see other files in this gist)
-
I notice that "101 Web Socket Protocol Handshake" is not the same as "101 Switching Protocols".
- Per this it doesn't matter.
-
In order to support multiple connection types, there must be some way of distinguishing between connections
-
It looks like libwebsockets is using the
Sec-WebSocket-Protocol
field for this -
It looks like Simple-WebSocket-Server is using specifying the HTTP Resource for this
-
Here's what RFC 6455 says about the field in question:
11.3.4. Sec-WebSocket-Protocol This section describes a header field registered in the Permanent Message Header Field Names registry [RFC3864]. Header field name Sec-WebSocket-Protocol Applicable protocol http Status standard Author/Change controller IETF Specification document(s) RFC 6455 Related information This header field is only used for the WebSocket opening handshake. The |Sec-WebSocket-Protocol| header field is used in the WebSocket opening handshake. It is sent from the client to the server and back from the server to the client to confirm the subprotocol of the connection. This enables scripts to both select a subprotocol and be sure that the server agreed to serve that subprotocol.
-
I think I have conflated the protocol string with the endpoint string. Either of these should work:
-
Expand WSS client to allow me to specify
Sec-WebSocket-Protocol
in the handshake, and include "controller-sky" in that field, then libwebsockets will have what it needs to route traffic to the the correct callback. -
Configure libwebsockets to listen for connections on the /sky/api/v2/controller-sky resource, and assume that connections there are part of the 'controller-sky' protocol