diff --git a/envoy/tcp/async_tcp_client.h b/envoy/tcp/async_tcp_client.h index 80b2e79b1de5..bd367a55db1b 100644 --- a/envoy/tcp/async_tcp_client.h +++ b/envoy/tcp/async_tcp_client.h @@ -40,8 +40,9 @@ class AsyncTcpClient { /** * Connect to a remote host. Errors or connection events are reported via the - * event callback registered via setAsyncTcpClientCallbacks(). We need to set the - * callbacks again to call connect() after the connection is disconnected. + * event callback registered via setAsyncTcpClientCallbacks(). If the callbacks + * needs to be changed before reconnecting, it is required to set the callbacks + * again, before calling to connect() to attempting to reconnect. * @returns true if a new client has created and the connection is in progress. * @returns false if an underlying client exists and is connected or connecting. */ diff --git a/source/common/tcp/async_tcp_client_impl.cc b/source/common/tcp/async_tcp_client_impl.cc index 30a249dc1ba2..cfe4efbb8e52 100644 --- a/source/common/tcp/async_tcp_client_impl.cc +++ b/source/common/tcp/async_tcp_client_impl.cc @@ -35,6 +35,7 @@ bool AsyncTcpClientImpl::connect() { } cluster_info_->trafficStats()->upstream_cx_total_.inc(); + cluster_info_->trafficStats()->upstream_cx_active_.inc(); connection_->enableHalfClose(enable_half_close_); connection_->addConnectionCallbacks(*this); connection_->addReadFilter(std::make_shared(*this)); @@ -132,8 +133,6 @@ void AsyncTcpClientImpl::onEvent(Network::ConnectionEvent event) { callbacks_->onEvent(event); } } else { - cluster_info_->trafficStats()->upstream_cx_active_.inc(); - connected_ = true; conn_connect_ms_->complete(); conn_connect_ms_.reset();