ws ping pong on idle connections
authorAndy Green <andy@warmcat.com>
Fri, 15 Jul 2016 05:41:38 +0000 (13:41 +0800)
committerAndy Green <andy@warmcat.com>
Wed, 10 Aug 2016 13:20:23 +0000 (21:20 +0800)
commitf32d25051c72551528060e6f386150b826563f85
tree8d06aa60ca91a308e59ba8c0ec65064486811944
parent0fa6821214230c2f9ff57eb222c293b4e1c5b049
ws ping pong on idle connections

This adds a new member to the context creation info struct "ws_ping_pong_interval".

If nonzero, it sets the number of seconds that established ws connections are
allowed to be idle before a PING is forced to be sent.  If zero (the default) then
tracking of idle connection is disabled for backwards compatibility.

Timeouts cover both the period between decision to send the ping and it being
sent (because it needs the socket to become writeable), and the period between
the ping being sent and the PONG coming back.

INFO debug logs are issues when the timeout stuff is operating.

You can test the server side by running the test server hacked to set ws_ping_pong_interval
and debug log mask of 15.  Both the mirror protocol and the server-status protocol are
idle if nothing is happening and will trigger the PING / PONG testing.  (You can also
test using lwsws and /etc/lwsws/conf with "ws-pingpong-secs": "20" in the global section)

For client, run the test client with -n -P 20 for 20s interval.  -n stops the test client
writing using the mirror protocol, so it will be idle and trigger the PING / PONGs.

The timeout interval may be up to +10s late, as lws checks for affected connections every
10s.
36 files changed:
README.lwsws.md
doc/html/functions.html
doc/html/functions_vars.html
doc/html/group__client.html
doc/html/group__context-and-vhost.js
doc/html/group__form-parsing.html
doc/html/group__sending-data.html
doc/html/group__smtp.html
doc/html/group__timeout.html
doc/html/group__vhost-mounts.html
doc/html/libwebsockets_8h.html
doc/html/libwebsockets_8h.js
doc/html/libwebsockets_8h_source.html
doc/html/md_README.lwsws.html
doc/html/navtreedata.js
doc/html/navtreeindex0.js
doc/html/navtreeindex1.js
doc/html/navtreeindex2.js
doc/html/navtreeindex3.js
doc/html/navtreeindex4.js
doc/html/structlws__context__creation__info.html
doc/html/structlws__context__creation__info.js
lib/client-parser.c
lib/client.c
lib/context.c
lib/lejp-conf.c
lib/libwebsockets.c
lib/libwebsockets.h
lib/output.c
lib/parsers.c
lib/private-libwebsockets.h
lib/server.c
lib/service.c
lib/ssl.c
lwsws/etc-lwsws-conf-EXAMPLE
test-server/test-client.c