1d4afb5ceSopenharmony_ci# lws minimal ws client PING
2d4afb5ceSopenharmony_ci
3d4afb5ceSopenharmony_ciThis connects to libwebsockets.org using the lws-mirror-protocol.
4d4afb5ceSopenharmony_ci
5d4afb5ceSopenharmony_ciIt sets a validity regime of testing validity with PING every 3s and failing
6d4afb5ceSopenharmony_ciif it didn't get the PONG back within 10s.
7d4afb5ceSopenharmony_ci
8d4afb5ceSopenharmony_ci## build
9d4afb5ceSopenharmony_ci
10d4afb5ceSopenharmony_ci```
11d4afb5ceSopenharmony_ci $ cmake . && make
12d4afb5ceSopenharmony_ci```
13d4afb5ceSopenharmony_ci
14d4afb5ceSopenharmony_ci## Commandline Options
15d4afb5ceSopenharmony_ci
16d4afb5ceSopenharmony_ciOption|Meaning
17d4afb5ceSopenharmony_ci---|---
18d4afb5ceSopenharmony_ci-d|Set logging verbosity (you want 1039 to see the validity ping / pong)
19d4afb5ceSopenharmony_ci--server|Use a specific server instead of libwebsockets.org, eg `--server localhost`.  Implies LCCSCF_ALLOW_SELFSIGNED
20d4afb5ceSopenharmony_ci--port|Use a specific port instead of 443, eg `--port 7681`
21d4afb5ceSopenharmony_ci--protocol|Use a specific ws subprotocol rather than lws-mirror-protocol, eg, `--protocol myprotocol`
22d4afb5ceSopenharmony_ci
23d4afb5ceSopenharmony_ci
24d4afb5ceSopenharmony_ci## usage
25d4afb5ceSopenharmony_ci
26d4afb5ceSopenharmony_ciJust run it, wait for the connect and then there will be PINGs sent
27d4afb5ceSopenharmony_ciat 5s intervals.
28d4afb5ceSopenharmony_ci
29d4afb5ceSopenharmony_ci```
30d4afb5ceSopenharmony_ci $ ./lws-minimal-ws-client-ping -d1039
31d4afb5ceSopenharmony_ci[2020/03/18 13:13:47:1114] U: LWS minimal ws client PING
32d4afb5ceSopenharmony_ci[2020/03/18 13:13:47:1503] I: Initial logging level 1039
33d4afb5ceSopenharmony_ci[2020/03/18 13:13:47:1507] I: Libwebsockets version: 4.0.99 v4.0.0-20-gc6165f868
34d4afb5ceSopenharmony_ci[2020/03/18 13:13:47:1508] I: IPV6 not compiled in
35d4afb5ceSopenharmony_ci[2020/03/18 13:13:47:1512] I:  LWS_DEF_HEADER_LEN    : 4096
36d4afb5ceSopenharmony_ci[2020/03/18 13:13:47:1514] I:  LWS_MAX_SMP           : 1
37d4afb5ceSopenharmony_ci[2020/03/18 13:13:47:1519] I:  sizeof (*info)        : 720
38d4afb5ceSopenharmony_ci[2020/03/18 13:13:47:1520] I:  SYSTEM_RANDOM_FILEPATH: '/dev/urandom'
39d4afb5ceSopenharmony_ci[2020/03/18 13:13:47:1522] I:  HTTP2 support         : available
40d4afb5ceSopenharmony_ci[2020/03/18 13:13:47:1552] N: lws_create_context: using ss proxy bind '(null)', port 0, ads '(null)'
41d4afb5ceSopenharmony_ci[2020/03/18 13:13:47:1557] I: context created
42d4afb5ceSopenharmony_ci[2020/03/18 13:13:47:1575] I: Using event loop: poll
43d4afb5ceSopenharmony_ci[2020/03/18 13:13:47:1583] I: Default ALPN advertisment: h2,http/1.1
44d4afb5ceSopenharmony_ci[2020/03/18 13:13:47:1585] I:  default timeout (secs): 20
45d4afb5ceSopenharmony_ci[2020/03/18 13:13:47:1614] I:  Threads: 1 each 5 fds
46d4afb5ceSopenharmony_ci[2020/03/18 13:13:47:1623] I:  mem: context:          8152 B (4056 ctx + (1 thr x 4096))
47d4afb5ceSopenharmony_ci[2020/03/18 13:13:47:1625] I:  mem: http hdr size:   (4096 + 976), max count 5
48d4afb5ceSopenharmony_ci[2020/03/18 13:13:47:1629] I:  mem: pollfd map:         40 B
49d4afb5ceSopenharmony_ci[2020/03/18 13:13:47:1633] I:  mem: platform fd map:    40 B
50d4afb5ceSopenharmony_ci[2020/03/18 13:13:47:1692] I:  Compiled with OpenSSL support
51d4afb5ceSopenharmony_ci[2020/03/18 13:13:47:1695] I: Doing SSL library init
52d4afb5ceSopenharmony_ci[2020/03/18 13:13:47:3103] I:  canonical_hostname = constance
53d4afb5ceSopenharmony_ci[2020/03/18 13:13:47:3140] I: Creating Vhost 'default' (serving disabled), 4 protocols, IPv6 off
54d4afb5ceSopenharmony_ci[2020/03/18 13:13:47:4072] I: lws_tls_client_create_vhost_context: vh default: created new client ctx 0
55d4afb5ceSopenharmony_ci[2020/03/18 13:13:47:7468] I: created client ssl context for default
56d4afb5ceSopenharmony_ci[2020/03/18 13:13:47:7482] I: Creating Vhost 'default' (serving disabled), 4 protocols, IPv6 off
57d4afb5ceSopenharmony_ci[2020/03/18 13:13:47:7490] I: lws_tls_client_create_vhost_context: vh default: reusing client ctx 0: use 2
58d4afb5ceSopenharmony_ci[2020/03/18 13:13:47:7491] I: created client ssl context for default
59d4afb5ceSopenharmony_ci[2020/03/18 13:13:47:7494] I:  mem: per-conn:          792 bytes + protocol rx buf
60d4afb5ceSopenharmony_ci[2020/03/18 13:13:47:7497] I: lws_plat_drop_app_privileges: not changing group
61d4afb5ceSopenharmony_ci[2020/03/18 13:13:47:7499] I: lws_plat_drop_app_privileges: not changing user
62d4afb5ceSopenharmony_ci[2020/03/18 13:13:47:7512] I: lws_cancel_service
63d4afb5ceSopenharmony_ci[2020/03/18 13:13:47:7568] I: lws_state_notify_protocol_init: LWS_SYSTATE_CPD_PRE_TIME
64d4afb5ceSopenharmony_ci[2020/03/18 13:13:47:7577] N: lws_ss_create: unknown stream type captive_portal_detect
65d4afb5ceSopenharmony_ci[2020/03/18 13:13:47:7580] I: lws_ss_sys_cpd: Create stream failed (policy?)
66d4afb5ceSopenharmony_ci[2020/03/18 13:13:47:7582] I: lws_state_notify_protocol_init: LWS_SYSTATE_CPD_PRE_TIME
67d4afb5ceSopenharmony_ci[2020/03/18 13:13:47:7582] N: lws_ss_create: unknown stream type captive_portal_detect
68d4afb5ceSopenharmony_ci[2020/03/18 13:13:47:7583] I: lws_ss_sys_cpd: Create stream failed (policy?)
69d4afb5ceSopenharmony_ci[2020/03/18 13:13:47:7585] I: lws_state_notify_protocol_init: doing protocol init on POLICY_VALID
70d4afb5ceSopenharmony_ci[2020/03/18 13:13:47:7588] I: lws_protocol_init
71d4afb5ceSopenharmony_ci[2020/03/18 13:13:47:7623] I: lws_state_transition_steps: CONTEXT_CREATED -> OPERATIONAL
72d4afb5ceSopenharmony_ci[2020/03/18 13:13:47:7628] N: connect_cb: connecting
73d4afb5ceSopenharmony_ci[2020/03/18 13:13:47:7656] I: lws_client_connect_via_info: role binding to h1
74d4afb5ceSopenharmony_ci[2020/03/18 13:13:47:7662] I: lws_client_connect_via_info: protocol binding to lws-ping-test
75d4afb5ceSopenharmony_ci[2020/03/18 13:13:47:7699] I: lws_client_connect_via_info: wsi 0x5669090: h1 lws-ping-test entry
76d4afb5ceSopenharmony_ci[2020/03/18 13:13:47:7720] I: lws_header_table_attach: wsi 0x5669090: ah (nil) (tsi 0, count = 0) in
77d4afb5ceSopenharmony_ci[2020/03/18 13:13:47:7729] I: _lws_create_ah: created ah 0x5669620 (size 4096): pool length 1
78d4afb5ceSopenharmony_ci[2020/03/18 13:13:47:7735] I: lws_header_table_attach: did attach wsi 0x5669090: ah 0x5669620: count 1 (on exit)
79d4afb5ceSopenharmony_ci[2020/03/18 13:13:47:7780] I: lws_client_connect_2_dnsreq: 0x5669090: lookup libwebsockets.org:443
80d4afb5ceSopenharmony_ci[2020/03/18 13:13:47:8784] I: lws_getaddrinfo46: getaddrinfo 'libwebsockets.org' says 0
81d4afb5ceSopenharmony_ci[2020/03/18 13:13:47:8804] I: lws_client_connect_3_connect: libwebsockets.org ipv4 46.105.127.147
82d4afb5ceSopenharmony_ci[2020/03/18 13:13:47:9176] I: lws_client_connect_3_connect: getsockopt check: conn OK
83d4afb5ceSopenharmony_ci[2020/03/18 13:13:47:9179] I: lws_client_connect_3_connect: Connection started 0x5682cc0
84d4afb5ceSopenharmony_ci[2020/03/18 13:13:47:9197] I: lws_client_connect_4_established: wsi 0x5669090: h1 lws-ping-test client created own conn (raw 0) vh defaultm st 0x202
85d4afb5ceSopenharmony_ci[2020/03/18 13:13:47:9418] I: h1 client conn using alpn list 'http/1.1'
86d4afb5ceSopenharmony_ci[2020/03/18 13:13:48:4523] I: lws_role_call_alpn_negotiated: 'http/1.1'
87d4afb5ceSopenharmony_ci[2020/03/18 13:13:48:4531] I: client connect OK
88d4afb5ceSopenharmony_ci[2020/03/18 13:13:48:4543] I: lws_openssl_describe_cipher: wsi 0x5669090: TLS_AES_256_GCM_SHA384, TLS_AES_256_GCM_SHA384, 256 bits, TLSv1.3
89d4afb5ceSopenharmony_ci[2020/03/18 13:13:48:4717] I: lws_client_socket_service: HANDSHAKE2: 0x5669090: sending headers (wsistate 0x10000204), w sock 5
90d4afb5ceSopenharmony_ci[2020/03/18 13:13:48:4992] I: lws_buflist_aware_read: wsi 0x5669090: lws_client_socket_service: ssl_capable_read -4
91d4afb5ceSopenharmony_ci[2020/03/18 13:13:48:5005] I: lws_buflist_aware_read: wsi 0x5669090: lws_client_socket_service: ssl_capable_read 174
92d4afb5ceSopenharmony_ci[2020/03/18 13:13:48:5166] I: __lws_header_table_detach: wsi 0x5669090: ah 0x5669620 (tsi=0, count = 1)
93d4afb5ceSopenharmony_ci[2020/03/18 13:13:48:5171] I: __lws_header_table_detach: nobody usable waiting
94d4afb5ceSopenharmony_ci[2020/03/18 13:13:48:5175] I: _lws_destroy_ah: freed ah 0x5669620 : pool length 0
95d4afb5ceSopenharmony_ci[2020/03/18 13:13:48:5180] I: __lws_header_table_detach: wsi 0x5669090: ah 0x5669620 (tsi=0, count = 0)
96d4afb5ceSopenharmony_ci[2020/03/18 13:13:48:5197] I: _lws_validity_confirmed_role: wsi 0x5669090: setting validity timer 3s (hup 0)
97d4afb5ceSopenharmony_ci[2020/03/18 13:13:48:5208] U: callback_minimal_broker: established
98d4afb5ceSopenharmony_ci[2020/03/18 13:13:51:5218] I: lws_validity_cb: wsi 0x5669090: scheduling validity check
99d4afb5ceSopenharmony_ci[2020/03/18 13:13:51:5325] I: rops_handle_POLLOUT_ws: issuing ping on wsi 0x5669090: ws lws-ping-test h2: 0
100d4afb5ceSopenharmony_ci[2020/03/18 13:13:51:5504] I: lws_issue_raw: ssl_capable_write (6) says 6
101d4afb5ceSopenharmony_ci[2020/03/18 13:13:51:5809] I: lws_ws_client_rx_sm: client 0x5669090 received pong
102d4afb5ceSopenharmony_ci[2020/03/18 13:13:51:5819] I: _lws_validity_confirmed_role: wsi 0x5669090: setting validity timer 3s (hup 0)
103d4afb5ceSopenharmony_ci[2020/03/18 13:13:51:5831] I: Client doing pong callback
104d4afb5ceSopenharmony_ci[2020/03/18 13:13:54:5821] I: lws_validity_cb: wsi 0x5669090: scheduling validity check
105d4afb5ceSopenharmony_ci[2020/03/18 13:13:54:5825] I: rops_handle_POLLOUT_ws: issuing ping on wsi 0x5669090: ws lws-ping-test h2: 0
106d4afb5ceSopenharmony_ci[2020/03/18 13:13:54:5833] I: lws_issue_raw: ssl_capable_write (6) says 6
107d4afb5ceSopenharmony_ci[2020/03/18 13:13:54:6258] I: lws_ws_client_rx_sm: client 0x5669090 received pong
108d4afb5ceSopenharmony_ci[2020/03/18 13:13:54:6261] I: _lws_validity_confirmed_role: wsi 0x5669090: setting validity timer 3s (hup 0)
109d4afb5ceSopenharmony_ci[2020/03/18 13:13:54:6263] I: Client doing pong callback
110d4afb5ceSopenharmony_ci[2020/03/18 13:13:57:6263] I: lws_validity_cb: wsi 0x5669090: scheduling validity check
111d4afb5ceSopenharmony_ci[2020/03/18 13:13:57:6267] I: rops_handle_POLLOUT_ws: issuing ping on wsi 0x5669090: ws lws-ping-test h2: 0
112d4afb5ceSopenharmony_ci[2020/03/18 13:13:57:6275] I: lws_issue_raw: ssl_capable_write (6) says 6
113d4afb5ceSopenharmony_ci[2020/03/18 13:13:58:0034] I: lws_ws_client_rx_sm: client 0x5669090 received pong
114d4afb5ceSopenharmony_ci
115d4afb5ceSopenharmony_ci...
116d4afb5ceSopenharmony_ci```
117d4afb5ceSopenharmony_ci
118