From 8ec1a4d90fae0f8ec0477f84f21ef6954770f6f4 Mon Sep 17 00:00:00 2001 From: Vinnie Falco Date: Mon, 1 Apr 2019 18:14:25 -0700 Subject: [PATCH] Fix websocket keep-alive ping expiration --- CHANGELOG.md | 1 + include/boost/beast/websocket/impl/stream_impl.hpp | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a7bc1908..937b2bdf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ Version 244: * Tidy up declval in some traits +* Fix websocket keep-alive ping expiration -------------------------------------------------------------------------------- diff --git a/include/boost/beast/websocket/impl/stream_impl.hpp b/include/boost/beast/websocket/impl/stream_impl.hpp index 0c8834fb..ec5557c3 100644 --- a/include/boost/beast/websocket/impl/stream_impl.hpp +++ b/include/boost/beast/websocket/impl/stream_impl.hpp @@ -424,8 +424,12 @@ struct stream::impl_type if(timeout_opt.idle_timeout != none()) { idle_counter = 0; - timer.expires_after( - timeout_opt.idle_timeout); + if(timeout_opt.keep_alive_pings) + timer.expires_after( + timeout_opt.idle_timeout / 2); + else + timer.expires_after( + timeout_opt.idle_timeout); timer.async_wait( timeout_handler( ex, this->weak_from_this()));