1
0
Fork 0
mirror of https://github.com/warmcat/libwebsockets.git synced 2025-03-16 00:00:07 +01:00
libwebsockets/minimal-examples/ws-client/minimal-ws-client
Andy Green 06662a64fa LE-root-cert-update
warmcat.com and libwebsockets.org use Let's Encrypt certificates... LE
have changed their CA signing arrangements and after 2021-01-12 (the
point I renewed the LE server certs and received one signed using the
new arrangements) it's required to trust new root certs for the examples
to connect to warmcat.com and libwebsockets.org.

https://letsencrypt.org/2020/09/17/new-root-and-intermediates.html

This updates the in-tree CA copies, the remote policies on warmcat.com
have also been updated.

Just goes to show for real client infrastructure, you need to run your own
CA (that doesn't have to be trusted by anything outside the clients)
where you can control the CA lifetime.
2021-01-13 04:32:13 +00:00
..
CMakeLists.txt cmake: latest cmake shows dep warnings for scripts < 2.8.12 2020-12-06 19:44:54 +00:00
libwebsockets.org.cer LE-root-cert-update 2021-01-13 04:32:13 +00:00
minimal-ws-client.c client: rfc6724 dns results sorting 2020-11-28 10:58:07 +00:00
README.md minimal examples: ws client demonstrating retry and backoff 2020-02-04 14:16:18 +00:00

lws minimal ws client

This connects to libwebsockets.org using the dumb-increment-protocol.

It demonstrates how to use the connection retry and backoff stuff in lws.

build

 $ cmake . && make

Commandline Options

Option Meaning
-d Set logging verbosity
-s Use a specific server instead of libwebsockets.org, eg --server localhost. Implies LCCSCF_ALLOW_SELFSIGNED
-p Use a specific port instead of 443, eg --port 7681
-j Allow selfsigned tls cert
-k Allow insecure certs
-m Skip server hostname check
-e Allow expired certs
--protocol Use a specific ws subprotocol rather than dumb-increment-protocol, eg, --protocol myprotocol

usage

Just run it, it will connect to libwebsockets.org and spew incrementing numbers sent by the server at 20Hz

 $ ./lws-minimal-ws-client
[2020/01/22 05:38:47:3409] U: LWS minimal ws client
[2020/01/22 05:38:47:4456] N: Loading client CA for verification ./libwebsockets.org.cer
[2020/01/22 05:38:48:1649] U: callback_minimal: established
[2020/01/22 05:38:48:1739] N: 
[2020/01/22 05:38:48:1763] N: 0000: 30                                                 0               
[2020/01/22 05:38:48:1765] N: 

...

To test against the lws test server instead of libwebsockets.org, run the test server as

$ libwebsockets-test-server -s

and run this test app with

$ ./lws-minimal-ws-client -s localhost -p 7681 -j

You can kill and restart the server to confirm the client connection is re- established if done within the backoff period.