• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# h2 long poll in lws
2
3lws server and client can support "immortal" streams that are
4not subject to normal timeouts under a special condition.  These
5are read-only (to the client).
6
7Network connections that contain at least one immortal stream
8are themselves not subject to timeouts until the last immortal
9stream they are carrying closes.
10
11Because of this, it's recommended there is some other way of
12confirming that the client is still active.
13
14## Setting up lws server for h2 long poll
15
16Vhosts that wish to allow clients to serve these immortal
17streams need to set the info.options flag `LWS_SERVER_OPTION_VH_H2_HALF_CLOSED_LONG_POLL`
18at vhost creation time.  The JSON config equivalent is to set
19
20```
21"h2-half-closed-long-poll": "1"
22```
23
24on the vhost.  That's all that is needed.
25
26Streams continue to act normally for timeout with the exception
27client streams are allowed to signal they are half-closing by
28sending a zero-length DATA frame with END_STREAM set.  These
29streams are allowed to exist outside of any timeout and data
30can be sent on them at will in the server -> client direction.
31
32## Setting client streams for long poll
33
34An API is provided to allow established h2 client streams to
35transition to immortal mode and send the END_STREAM to the server
36to indicate it.
37
38```
39int
40lws_h2_client_stream_long_poll_rxonly(struct lws *wsi);
41```
42
43## Example applications
44
45You can confirm the long poll flow simply using example applications.
46Build and run `http-server/minimal-http-server-h2-long-poll` in one
47terminal.
48
49In another, build the usual `http-client/minimal-http-client` example
50and run it with the flags `-l --long-poll`
51
52The client will connect to the server and transition to the immortal mode.
53The server sends a timestamp every minute to the client, and that will
54stay up without timeouts.
55
56