diff --git a/network/src/channel.rs b/network/src/channel.rs index 6395212e8d..e58d8057f9 100644 --- a/network/src/channel.rs +++ b/network/src/channel.rs @@ -75,6 +75,10 @@ impl Protocols { ) -> Result { let stream = net::TcpStream::connect(addr) .await + .and_then(|s| { + s.set_nodelay(true)?; + Ok(s) + }) .map_err(NetworkConnectError::Io)?; info!( "Connecting Tcp to: {}", @@ -105,6 +109,12 @@ impl Protocols { continue; }, }; + if let Err(e) = stream.set_nodelay(true) { + warn!( + ?e, + "Failed to set TCP_NODELAY, client may have degraded latency" + ); + } let cid = cids.fetch_add(1, Ordering::Relaxed); info!(?remote_addr, ?cid, "Accepting Tcp from"); let metrics = ProtocolMetricCache::new(&cid.to_string(), Arc::clone(&metrics));