I try to implement a websocket client (with libwebsockets in C and it's not an option). As example, i used the test-client.c given with the library. My websocket-client actualy works fine with the test-server.c . But i experienced some complications to communicate with an nginx server.
As i understand, the handshack doesn't end up well because nginx doesn't know my websocket client's sub-protocol. Well, it appears, like in test-client.c i'm implementing my own sub-protocol (with its own name, its own callback function).
My questions are :
Is there a way to not use a specific websocket sub-protocol with libwebsockets ?
If not, am i supposed to implement an existing one (client side) like WAMP or something in this list? (I do not want to reinvent the wheel...)
If not, does it exist a "default" websocket subprotocol that i can specify to nginx and in which it could be compatible with my websocket-client ? (I'm only doing some simple send/receive action with my client. Implementing a libwebsockets client seems completly useless if it can only communicate with a libwebsockets server)
Are my questions relevant? If not why ? What am i missing ?
Any help is appreciated. Thanks!
As discussed with Andy, the libwebsockets designer (https://github.com/warmcat/libwebsockets/issues/834), the simpliest way to make it works is to not named the sub-protocol in the structure defining the websocket sub-protocol client's side :
/* list of supported sub-protocols and callbacks */
static struct lws_protocols ws_protocols[] = {
{ NULL, ws_callback, 0, 128, },
{ NULL, NULL, 0, 0 } /* end */
};
Libwebsockets client doesn't try to negociate with sec-websocket-protocol
in the header, the handshake works just fine with nginx.