Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

network: add timeout for transport connect #13610

Merged
merged 12 commits into from
Oct 27, 2020
7 changes: 4 additions & 3 deletions docs/root/faq/configuration/timeouts.rst
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,10 @@ TCP
is the amount of time that the TCP proxy will allow a connection to exist with no upstream
or downstream activity. The default idle timeout if not otherwise specified is *1 hour*.

TLS / Transport Socket
Transport Socket
----------------------

* The :ref:`transport_socket_connect_timeout <envoy_v3_api_field_config.listener.v3.FilterChain.transport_socket_connect_timeout>`
specifies the amount of time Envoy will wait for a downstream client to complete transport-level
negotiations. This can be used to limit the amount of time allowed to finish a TLS handshake
after establishing a TCP connection.
negotiations. When configured on a filter chain with a TLS or ALTS transport socket, this limits
the amount of time allowed to finish the encrypted handshake after establishing a TCP connection.
2 changes: 1 addition & 1 deletion source/common/network/connection_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -725,14 +725,14 @@ void ServerConnectionImpl::setTransportSocketConnectTimeout(std::chrono::millise
}

void ServerConnectionImpl::raiseEvent(ConnectionEvent event) {
ConnectionImpl::raiseEvent(event);
switch (event) {
case ConnectionEvent::Connected:
case ConnectionEvent::RemoteClose:
case ConnectionEvent::LocalClose:
transport_connect_pending_ = false;
transport_socket_connect_timer_.reset();
}
ConnectionImpl::raiseEvent(event);
}

void ServerConnectionImpl::onTransportSocketConnectTimeout() {
Expand Down
4 changes: 2 additions & 2 deletions test/common/network/connection_impl_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,6 @@ TEST_P(ConnectionImplTest, SetServerTransportSocketTimeout) {
std::move(mocks.transport_socket_), stream_info_, true);

EXPECT_CALL(*mock_timer, enableTimer(std::chrono::milliseconds(3 * 1000), _));

server_connection->setTransportSocketConnectTimeout(std::chrono::seconds(3));
EXPECT_CALL(*transport_socket, closeSocket(ConnectionEvent::LocalClose));
mock_timer->invokeCallback();
Expand All @@ -387,7 +386,8 @@ TEST_P(ConnectionImplTest, SetServerTransportSocketTimeoutAfterConnect) {
std::move(mocks.transport_socket_), stream_info_, true);

transport_socket->callbacks_->raiseEvent(ConnectionEvent::Connected);
// This should be a no-op.
// This should be a no-op. No timer should be created.
EXPECT_CALL(dispatcher, createTimer_(_)).Times(0);
server_connection->setTransportSocketConnectTimeout(std::chrono::seconds(3));

server_connection->close(ConnectionCloseType::NoFlush);
Expand Down