From f88eb79de4bfb00e99f8e63d50f9ce788f8306b5 Mon Sep 17 00:00:00 2001 From: tottoto Date: Tue, 21 May 2024 16:24:05 +0900 Subject: [PATCH] chore(transport): Use hyper timeout feature (#1497) --- tonic/src/transport/channel/endpoint.rs | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/tonic/src/transport/channel/endpoint.rs b/tonic/src/transport/channel/endpoint.rs index 597b4bc4d..1560326b7 100644 --- a/tonic/src/transport/channel/endpoint.rs +++ b/tonic/src/transport/channel/endpoint.rs @@ -337,16 +337,11 @@ impl Endpoint { http.enforce_http(false); http.set_nodelay(self.tcp_nodelay); http.set_keepalive(self.tcp_keepalive); + http.set_connect_timeout(self.connect_timeout); let connector = self.connector(http); - if let Some(connect_timeout) = self.connect_timeout { - let mut connector = hyper_timeout::TimeoutConnector::new(connector); - connector.set_connect_timeout(Some(connect_timeout)); - Channel::connect(connector, self.clone()).await - } else { - Channel::connect(connector, self.clone()).await - } + Channel::connect(connector, self.clone()).await } /// Create a channel from this config. @@ -358,16 +353,11 @@ impl Endpoint { http.enforce_http(false); http.set_nodelay(self.tcp_nodelay); http.set_keepalive(self.tcp_keepalive); + http.set_connect_timeout(self.connect_timeout); let connector = self.connector(http); - if let Some(connect_timeout) = self.connect_timeout { - let mut connector = hyper_timeout::TimeoutConnector::new(connector); - connector.set_connect_timeout(Some(connect_timeout)); - Channel::new(connector, self.clone()) - } else { - Channel::new(connector, self.clone()) - } + Channel::new(connector, self.clone()) } /// Connect with a custom connector.