Skip to content

Commit

Permalink
fix: 意料外的超时错误
Browse files Browse the repository at this point in the history
由代理引起
  • Loading branch information
itsusinn committed Jan 18, 2022
1 parent 5c0f838 commit b2b973e
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/net.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
use std::time::Duration;

fn default_reqwest_settings() -> reqwest::ClientBuilder {
// maybe we should configure it by ourselves
teloxide_core::net::default_reqwest_settings()
use reqwest::header::{HeaderMap, CONNECTION};

let mut headers = HeaderMap::new();
headers.insert(CONNECTION, "keep-alive".parse().unwrap());

let connect_timeout = Duration::from_secs(10);
let timeout = connect_timeout + Duration::from_secs(24);

reqwest::Client::builder()
.connect_timeout(connect_timeout)
.timeout(timeout)
.tcp_nodelay(true)
.default_headers(headers)
}
pub fn client_from_config() -> reqwest::Client {
use crate::config::CONFIG;
Expand Down

0 comments on commit b2b973e

Please sign in to comment.