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

fix too much unclosed sockets (file descriptor) #1413

Merged
merged 7 commits into from
Oct 8, 2019
9 changes: 7 additions & 2 deletions chain/telemetry/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
use std::time::Duration;
use std::u64;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no need to do this. u64::max_value() is available just fine without this use.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, fixed now. I'm confusing that why std::u64::max_value() => compile error. why it's not equivalent to use std::u64; u64::max_value()?
(u64::max_value() is just fine without this use too, as you said)


use actix::prelude::Future;
use actix::{Actor, Addr, Context, Handler, Message};
use actix_web::client::Client;
use actix_web::client::{Client, Connector};
use serde_derive::{Deserialize, Serialize};

/// Timeout for establishing connection.
Expand Down Expand Up @@ -32,7 +33,11 @@ impl Default for TelemetryActor {

impl TelemetryActor {
pub fn new(config: TelemetryConfig) -> Self {
let client = Client::build().timeout(CONNECT_TIMEOUT).finish();
let client = Client::build().timeout(CONNECT_TIMEOUT).connector(
Connector::new()
.conn_lifetime(Duration::from_secs(u64::max_value()))
.conn_keep_alive(Duration::from_secs(30))
.finish()).finish();
Self { config, client }
}
}
Expand Down