You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The below code creates one easy handle per endpoint and adds it to a multi handle to be performed asynchronously.
The endpoints vector contains a list of AWS ELBs which are associated with security groups that do not allow HTTP traffic. Therefore connections are timing out 100% of the time. However, as per the output below, os_errno() is sometimes reporting the expected error, 110, and sometimes reporting 0, indicating no issue with the connection.
use std::time::Duration;
use curl::{easy::{Easy2, Handler, WriteError}, multi::Multi};
use futures::future::join_all;
use tokio::time::sleep;
pub struct Collector(pub Vec<u8>);
impl Handler for Collector {
fn write(&mut self, data: &[u8]) -> Result<usize, WriteError> {
self.0.extend_from_slice(data);
Ok(data.len())
}
}
#[tokio::main(worker_threads = 1)]
async fn main() {
let endpoints = vec![
"xxx.com",
"yyy.com",
"zzz.com",
];
let mut f = vec![];
let mut handles = vec![];
for i in 0..50 {
let mut multi = Multi::new();
multi.pipelining(false, false).unwrap();
for &endpoint in &endpoints {
println!("{}", endpoint);
let mut handle = Easy2::new(Collector(Vec::new()));
handle
.connect_timeout(Duration::from_secs(2))
.unwrap();
handle.timeout(Duration::from_secs(5)).unwrap();
handle.url(endpoint).unwrap();
handle.forbid_reuse(true).unwrap();
let handle = multi.add2(handle).unwrap();
handles.push(handle);
}
f.push(send_requests(multi));
}
join_all(f).await;
for mut handle in handles {
println!("{:?}", handle.total_time());
println!("{:?}", handle.os_errno());
}
}
async fn send_requests(multi: Multi) {
while multi.perform().unwrap() > 0 {
sleep(Duration::from_millis(0)).await;
// OR tokio::task::yield_now().await;
}
}
I'm not sure if this is an issue with the curl crate, the code itself, or an underlying issue of the OS or libcurl. Any information that can help me understand this behaviour is much appreciated!
The text was updated successfully, but these errors were encountered:
Problem description
The below code creates one easy handle per endpoint and adds it to a multi handle to be performed asynchronously.
The endpoints vector contains a list of AWS ELBs which are associated with security groups that do not allow HTTP traffic. Therefore connections are timing out 100% of the time. However, as per the output below,
os_errno()
is sometimes reporting the expected error,110
, and sometimes reporting0
, indicating no issue with the connection.Output:
I'm not sure if this is an issue with the
curl
crate, the code itself, or an underlying issue of the OS or libcurl. Any information that can help me understand this behaviour is much appreciated!The text was updated successfully, but these errors were encountered: