~ knotless Search/
↑↓ move↵ open⇧↵ all results
0
0

The host drops a connection idle for 4 s, before its server closes it

Merged chadtmiller.com asked to merge into main from chadtmiller.com/group-host:host/idle-connections
crates/group-host/src/identity.rs+1−2
@@ -65,8 +65,7 @@ impl Resolver {
did_web_scheme: did_web_scheme.to_string(),
// A document or handle is at a host the caller names: one that
// redirects is not followed elsewhere.
http: reqwest::Client::builder()
.timeout(crate::OUTGOING_TIMEOUT)
http: crate::client_builder()
.redirect(reqwest::redirect::Policy::none())
.build()
.expect("a client builds"),
crates/group-host/src/lib.rs+15−1
@@ -140,9 +140,23 @@ impl Host {
/// server that takes a request and never answers holds nothing up longer.
pub const OUTGOING_TIMEOUT: std::time::Duration = std::time::Duration::from_secs(10);
/// How long the host keeps a connection to another server open with no
/// request on it: under the 5 s after which Node's HTTP server, which the
/// reference PDS and PLC run on, closes an idle one. A request sent on a
/// connection as its server closes it fails ("connection closed before
/// message completed"), so the host drops one before that can happen.
pub const IDLE_AT_MOST: std::time::Duration = std::time::Duration::from_secs(4);
/// What every client of the host's for other servers is built from.
pub fn client_builder() -> reqwest::ClientBuilder {
reqwest::Client::builder()
.timeout(OUTGOING_TIMEOUT)
.pool_idle_timeout(IDLE_AT_MOST)
}
/// A client for the host's requests to other servers.
pub fn client() -> reqwest::Client {
let built = reqwest::Client::builder().timeout(OUTGOING_TIMEOUT).build();
let built = client_builder().build();
built.expect("a client with a timeout builds")
}
crates/group-host/src/oauth_clients.rs+1−3
@@ -13,7 +13,6 @@ use reqwest::Url;
use serde_json::{Value, json};
use std::collections::HashMap;
use std::net::{IpAddr, SocketAddr};
use std::time::Duration;
pub const CLIENT_ASSERTION_TYPE: &str = "urn:ietf:params:oauth:client-assertion-type:jwt-bearer";
@@ -206,8 +205,7 @@ pub(crate) async fn pinned_client(
if !http_here && !addrs.iter().all(|a| public(a.ip())) {
return Err(format!("{url} is not at a public address"));
}
let pinned = reqwest::Client::builder()
.timeout(Duration::from_secs(10))
let pinned = crate::client_builder()
.redirect(reqwest::redirect::Policy::none())
.resolve_to_addrs(host.trim_matches(['[', ']']), &addrs)
.build()