forked from boostorg/beast
websockets: Count pings from server as activity for idle_timeout
If the stream is receiving control packets like ping, don't count it as idle. This means you can enable `timeout_opt.keep_alive_ping` on only one side to get heartbeat. Make tests that verify current behaviour. Update documentation to match changes in PR #2718. Addresses issue #2716
This commit is contained in:
committed by
Mohammad Nejati
parent
84115e5b13
commit
f9387fda71
@@ -439,12 +439,8 @@ struct stream<NextLayer, deflateSupported>::impl_type
|
||||
if(timeout_opt.idle_timeout != none())
|
||||
{
|
||||
idle_counter = 0;
|
||||
if(timeout_opt.keep_alive_pings)
|
||||
timer.expires_after(
|
||||
timeout_opt.idle_timeout / 2);
|
||||
else
|
||||
timer.expires_after(
|
||||
timeout_opt.idle_timeout);
|
||||
timer.expires_after(
|
||||
timeout_opt.idle_timeout / 2);
|
||||
|
||||
BOOST_ASIO_HANDLER_LOCATION((
|
||||
__FILE__, __LINE__,
|
||||
@@ -569,9 +565,9 @@ private:
|
||||
if(impl.timeout_opt.idle_timeout == none())
|
||||
return;
|
||||
|
||||
if( impl.timeout_opt.keep_alive_pings &&
|
||||
impl.idle_counter < 1)
|
||||
if( impl.idle_counter < 1 )
|
||||
{
|
||||
if( impl.timeout_opt.keep_alive_pings )
|
||||
{
|
||||
BOOST_ASIO_HANDLER_LOCATION((
|
||||
__FILE__, __LINE__,
|
||||
|
||||
@@ -116,8 +116,10 @@ struct stream_base
|
||||
An outstanding read operation must be pending, which will
|
||||
complete immediately the error @ref beast::error::timeout.
|
||||
|
||||
@li When `keep_alive_pings` is `false`, the connection will be closed.
|
||||
An outstanding read operation must be pending, which will
|
||||
@li When `keep_alive_pings` is `false`, the connection will
|
||||
be closed if there has been no activity. Both websocket
|
||||
message frames and control frames count as activity. An
|
||||
outstanding read operation must be pending, which will
|
||||
complete immediately the error @ref beast::error::timeout.
|
||||
*/
|
||||
bool keep_alive_pings;
|
||||
|
||||
Reference in New Issue
Block a user