summaryrefslogtreecommitdiff
path: root/http/websocket.hpp
diff options
context:
space:
mode:
authordhineskumare <dhineskumare@ami.com>2021-07-08 13:36:49 +0300
committerEd Tanous <ed@tanous.net>2021-07-23 18:51:56 +0300
commit02bdd9672c7619cc1e11fe3daed8e3ec092b207b (patch)
tree72882ee8374751068951abbea358d9ecb15e66e6 /http/websocket.hpp
parent9d41aec68bc35dd6e7ae6c34f3678f38377f8731 (diff)
downloadbmcweb-02bdd9672c7619cc1e11fe3daed8e3ec092b207b.tar.xz
Enable Keepalive to server role
This commit is for, enable the timeout setting with suggested values for server(300sec) role. Server's keep_alive_pings is true by default, so time to server role is become 300/2 sec. It is used for to check server/client communication status in every 150sec. There is a timeout option to websocket stream, which is created by boost library .By default, timeouts on websocket streams are disabled. The way to turn them on is to set the suggested timeout settings on the stream. Idle Timeout is configured as 300sec to server role by default. We can adjust the timeout value which we want exactly by changing the idle_timeout. Depends on keep_alive_pings , the suggested value of the idle timeout will be consider. Keep_alive_pings of server role is set to `true` by default in boost library. So idle_timeout of server role is consider as 300/2 sec by default. https://www.boost.org/doc/libs/master/libs/beast/doc/html/beast/using_websocket/timeouts.html Tested: Redirected Virtual media. connection has established successfully. Media instance gets redirected to host machine. Disconnected the client network. Keepalive idle timeout for server role will found stream miss communication status in next 150sec cycle, and virtual media websocket will be stop gracefully. Existing behaviour: 900sec (15 minutes) will be taken for closing the websocket connection due to network disconnection. Signed-off-by: Dhines Kumar E <dhineskumare@ami.com> Change-Id: Id68d6a5c9b0139b1c70f80e9265a3e4d96e2ee87
Diffstat (limited to 'http/websocket.hpp')
-rw-r--r--http/websocket.hpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/http/websocket.hpp b/http/websocket.hpp
index 40fbcc01b4..30a9b9f4b5 100644
--- a/http/websocket.hpp
+++ b/http/websocket.hpp
@@ -78,6 +78,9 @@ class ConnectionImpl : public Connection
closeHandler(std::move(closeHandler)),
errorHandler(std::move(errorHandler)), session(reqIn.session)
{
+ /* Turn on the timeouts on websocket stream to server role */
+ ws.set_option(boost::beast::websocket::stream_base::timeout::suggested(
+ boost::beast::role_type::server));
BMCWEB_LOG_DEBUG << "Creating new connection " << this;
}