This is an automated email from the ASF dual-hosted git repository. briang pushed a commit to branch master in repository https://git-dual.apache.org/repos/asf/trafficserver.git
The following commit(s) were added to refs/heads/master by this push: new 1466cca TS-3922: Add independent websocket timeouts. This closes #590 1466cca is described below commit 1466ccadd2c3cee31de9835249bf24f29a1d9ea1 Author: Brian Geffon <bri...@apache.org> AuthorDate: Wed Apr 20 21:32:03 2016 -0700 TS-3922: Add independent websocket timeouts. This closes #590 --- doc/admin-guide/files/records.config.en.rst | 12 ++++++++++++ iocore/net/UnixNet.cc | 9 +++++---- mgmt/RecordsConfig.cc | 4 ++++ proxy/http/HttpConfig.cc | 5 +++++ proxy/http/HttpConfig.h | 16 +++++++++------- proxy/http/HttpSM.cc | 14 ++++++++++++++ 6 files changed, 49 insertions(+), 11 deletions(-) diff --git a/doc/admin-guide/files/records.config.en.rst b/doc/admin-guide/files/records.config.en.rst index b3421ba..a5f5889 100644 --- a/doc/admin-guide/files/records.config.en.rst +++ b/doc/admin-guide/files/records.config.en.rst @@ -1121,6 +1121,18 @@ HTTP Connection Timeouts Specifies how long Traffic Server keeps connections to origin servers open if the transaction stalls. +.. ts:cv:: CONFIG proxy.config.websocket.no_activity_timeout INT 600 + :reloadable: + :overridable: + + Specifies how long Traffic Server keeps connections open if a websocket stalls. + +.. ts:cv:: CONFIG proxy.config.websocket.active_timeout INT 3600 + :reloadable: + :overridable: + + The maximum amount of time Traffic Server keeps websocket connections open. + .. ts:cv:: CONFIG proxy.config.http.transaction_active_timeout_in INT 900 :reloadable: diff --git a/iocore/net/UnixNet.cc b/iocore/net/UnixNet.cc index d749844..5066b47 100644 --- a/iocore/net/UnixNet.cc +++ b/iocore/net/UnixNet.cc @@ -85,8 +85,9 @@ public: vc->set_inactivity_timeout(HRTIME_SECONDS(default_inactivity_timeout)); NET_INCREMENT_DYN_STAT(default_inactivity_timeout_stat); } else { - Debug("inactivity_cop_verbose", "vc: %p now: %" PRId64 " timeout at: %" PRId64 " timeout in: %" PRId64, vc, now, - ink_hrtime_to_sec(vc->next_inactivity_timeout_at), ink_hrtime_to_sec(vc->inactivity_timeout_in)); + Debug("inactivity_cop_verbose", "vc: %p now: %" PRId64 " timeout at: %" PRId64 " timeout in: %" PRId64, vc, + ink_hrtime_to_sec(now), ink_hrtime_to_sec(vc->next_inactivity_timeout_at), + ink_hrtime_to_sec(vc->inactivity_timeout_in)); } if (vc->next_inactivity_timeout_at && vc->next_inactivity_timeout_at < now) { @@ -96,8 +97,8 @@ public: NET_SUM_DYN_STAT(keep_alive_queue_timeout_total_stat, diff); NET_INCREMENT_DYN_STAT(keep_alive_queue_timeout_count_stat); } - Debug("inactivity_cop_verbose", "vc: %p now: %" PRId64 " timeout at: %" PRId64 " timeout in: %" PRId64, vc, now, - vc->next_inactivity_timeout_at, vc->inactivity_timeout_in); + Debug("inactivity_cop_verbose", "vc: %p now: %" PRId64 " timeout at: %" PRId64 " timeout in: %" PRId64, vc, + ink_hrtime_to_sec(now), vc->next_inactivity_timeout_at, vc->inactivity_timeout_in); vc->handleEvent(EVENT_IMMEDIATE, e); } } diff --git a/mgmt/RecordsConfig.cc b/mgmt/RecordsConfig.cc index 55d9cdc..0ce9df9 100644 --- a/mgmt/RecordsConfig.cc +++ b/mgmt/RecordsConfig.cc @@ -539,6 +539,10 @@ static const RecordElement RecordsConfig[] = , {RECT_CONFIG, "proxy.config.http.keep_alive_no_activity_timeout_out", RECD_INT, "120", RECU_DYNAMIC, RR_NULL, RECC_STR, "^[0-9]+$", RECA_NULL} , + {RECT_CONFIG, "proxy.config.websocket.no_activity_timeout", RECD_INT, "600", RECU_DYNAMIC, RR_NULL, RECC_STR, "^[0-9]+$", RECA_NULL} + , + {RECT_CONFIG, "proxy.config.websocket.active_timeout", RECD_INT, "3600", RECU_DYNAMIC, RR_NULL, RECC_STR, "^[0-9]+$", RECA_NULL} + , {RECT_CONFIG, "proxy.config.http.transaction_no_activity_timeout_in", RECD_INT, "30", RECU_DYNAMIC, RR_NULL, RECC_STR, "^[0-9]+$", RECA_NULL} , {RECT_CONFIG, "proxy.config.http.transaction_no_activity_timeout_out", RECD_INT, "30", RECU_DYNAMIC, RR_NULL, RECC_STR, "^[0-9]+$", RECA_NULL} diff --git a/proxy/http/HttpConfig.cc b/proxy/http/HttpConfig.cc index 3ab4a88..885ff3c 100644 --- a/proxy/http/HttpConfig.cc +++ b/proxy/http/HttpConfig.cc @@ -942,6 +942,9 @@ HttpConfig::startup() "proxy.config.http.transaction_no_activity_timeout_in"); HttpEstablishStaticConfigLongLong(c.oride.transaction_no_activity_timeout_out, "proxy.config.http.transaction_no_activity_timeout_out"); + HttpEstablishStaticConfigLongLong(c.oride.websocket_active_timeout, "proxy.config.websocket.active_timeout"); + HttpEstablishStaticConfigLongLong(c.oride.websocket_inactive_timeout, "proxy.config.websocket.no_activity_timeout"); + HttpEstablishStaticConfigLongLong(c.transaction_active_timeout_in, "proxy.config.http.transaction_active_timeout_in"); HttpEstablishStaticConfigLongLong(c.oride.transaction_active_timeout_out, "proxy.config.http.transaction_active_timeout_out"); HttpEstablishStaticConfigLongLong(c.accept_no_activity_timeout, "proxy.config.http.accept_no_activity_timeout"); @@ -1219,6 +1222,8 @@ HttpConfig::reconfigure() params->oride.transaction_no_activity_timeout_out = m_master.oride.transaction_no_activity_timeout_out; params->transaction_active_timeout_in = m_master.transaction_active_timeout_in; params->oride.transaction_active_timeout_out = m_master.oride.transaction_active_timeout_out; + params->oride.websocket_active_timeout = m_master.oride.websocket_active_timeout; + params->oride.websocket_inactive_timeout = m_master.oride.websocket_inactive_timeout; params->accept_no_activity_timeout = m_master.accept_no_activity_timeout; params->oride.background_fill_active_timeout = m_master.oride.background_fill_active_timeout; params->oride.background_fill_threshold = m_master.oride.background_fill_threshold; diff --git a/proxy/http/HttpConfig.h b/proxy/http/HttpConfig.h index 824ea7c..17d327a 100644 --- a/proxy/http/HttpConfig.h +++ b/proxy/http/HttpConfig.h @@ -377,13 +377,13 @@ struct OverridableHttpConfigParams { cache_heuristic_min_lifetime(3600), cache_heuristic_max_lifetime(86400), cache_guaranteed_min_lifetime(0), cache_guaranteed_max_lifetime(31536000), cache_max_stale_age(604800), keep_alive_no_activity_timeout_in(115), keep_alive_no_activity_timeout_out(120), transaction_no_activity_timeout_in(30), transaction_no_activity_timeout_out(30), - transaction_active_timeout_out(0), origin_max_connections(0), origin_max_connections_queue(0), - attach_server_session_to_client(0), connect_attempts_max_retries(0), connect_attempts_max_retries_dead_server(3), - connect_attempts_rr_retries(3), connect_attempts_timeout(30), post_connect_attempts_timeout(1800), down_server_timeout(300), - client_abort_threshold(10), freshness_fuzz_time(240), freshness_fuzz_min_time(0), max_cache_open_read_retries(-1), - cache_open_read_retry_time(10), cache_generation_number(-1), max_cache_open_write_retries(1), - background_fill_active_timeout(60), http_chunking_size(4096), flow_high_water_mark(0), flow_low_water_mark(0), - default_buffer_size_index(8), default_buffer_water_mark(32768), slow_log_threshold(0), + transaction_active_timeout_out(0), websocket_active_timeout(3600), websocket_inactive_timeout(600), origin_max_connections(0), + origin_max_connections_queue(0), attach_server_session_to_client(0), connect_attempts_max_retries(0), + connect_attempts_max_retries_dead_server(3), connect_attempts_rr_retries(3), connect_attempts_timeout(30), + post_connect_attempts_timeout(1800), down_server_timeout(300), client_abort_threshold(10), freshness_fuzz_time(240), + freshness_fuzz_min_time(0), max_cache_open_read_retries(-1), cache_open_read_retry_time(10), cache_generation_number(-1), + max_cache_open_write_retries(1), background_fill_active_timeout(60), http_chunking_size(4096), flow_high_water_mark(0), + flow_low_water_mark(0), default_buffer_size_index(8), default_buffer_water_mark(32768), slow_log_threshold(0), // Strings / floats must come last body_factory_template_base(NULL), body_factory_template_base_len(0), proxy_response_server_string(NULL), @@ -527,6 +527,8 @@ struct OverridableHttpConfigParams { MgmtInt transaction_no_activity_timeout_in; MgmtInt transaction_no_activity_timeout_out; MgmtInt transaction_active_timeout_out; + MgmtInt websocket_active_timeout; + MgmtInt websocket_inactive_timeout; MgmtInt origin_max_connections; MgmtInt origin_max_connections_queue; diff --git a/proxy/http/HttpSM.cc b/proxy/http/HttpSM.cc index e5b5c05..0d27e23 100644 --- a/proxy/http/HttpSM.cc +++ b/proxy/http/HttpSM.cc @@ -1584,6 +1584,20 @@ HttpSM::handle_api_return() // a blind tunnel. if (t_state.is_websocket) { HTTP_INCREMENT_DYN_STAT(http_websocket_current_active_client_connections_stat); + + if (ua_session) { + DebugSM("http_websocket", "(client session) Setting websocket active timeout=%ld s and inactive timeout=%ld s", + t_state.txn_conf->websocket_active_timeout, t_state.txn_conf->websocket_inactive_timeout); + ua_session->get_netvc()->set_active_timeout(HRTIME_SECONDS(t_state.txn_conf->websocket_active_timeout)); + ua_session->get_netvc()->set_inactivity_timeout(HRTIME_SECONDS(t_state.txn_conf->websocket_inactive_timeout)); + } + + if (server_session) { + DebugSM("http_websocket", "(server session) Setting websocket active timeout=%ld s and inactive timeout=%ld s", + t_state.txn_conf->websocket_active_timeout, t_state.txn_conf->websocket_inactive_timeout); + server_session->get_netvc()->set_active_timeout(HRTIME_SECONDS(t_state.txn_conf->websocket_active_timeout)); + server_session->get_netvc()->set_inactivity_timeout(HRTIME_SECONDS(t_state.txn_conf->websocket_inactive_timeout)); + } } setup_blind_tunnel(true); -- To stop receiving notification emails like this one, please contact ['"commits@trafficserver.apache.org" <commits@trafficserver.apache.org>'].