Timeout after 20 seconds (#3054)
This commit is contained in:
committed by
Antioch Peverell
parent
973a03c826
commit
84172216a5
+7
-1
@@ -23,8 +23,10 @@ use hyper::header::{ACCEPT, AUTHORIZATION, CONTENT_TYPE, USER_AGENT};
|
||||
use hyper::rt::{Future, Stream};
|
||||
use hyper::{Body, Client, Request};
|
||||
use hyper_rustls;
|
||||
use hyper_timeout::TimeoutConnector;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_json;
|
||||
use std::time::Duration;
|
||||
use tokio::runtime::Runtime;
|
||||
|
||||
pub type ClientResponseFuture<T> = Box<dyn Future<Item = T, Error = Error> + Send>;
|
||||
@@ -195,7 +197,11 @@ where
|
||||
|
||||
fn send_request_async(req: Request<Body>) -> Box<dyn Future<Item = String, Error = Error> + Send> {
|
||||
let https = hyper_rustls::HttpsConnector::new(1);
|
||||
let client = Client::builder().build::<_, Body>(https);
|
||||
let mut connector = TimeoutConnector::new(https);
|
||||
connector.set_connect_timeout(Some(Duration::from_secs(20)));
|
||||
connector.set_read_timeout(Some(Duration::from_secs(20)));
|
||||
connector.set_write_timeout(Some(Duration::from_secs(20)));
|
||||
let client = Client::builder().build::<_, hyper::Body>(connector);
|
||||
Box::new(
|
||||
client
|
||||
.request(req)
|
||||
|
||||
Reference in New Issue
Block a user