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

Keep-alive is disabled when using SOCKS #716

Open
HirbodBehnam opened this issue Feb 1, 2024 · 1 comment
Open

Keep-alive is disabled when using SOCKS #716

HirbodBehnam opened this issue Feb 1, 2024 · 1 comment

Comments

@HirbodBehnam
Copy link

Hello
I've discovered that if you use socks5 proxy when building the Agent, ureq will instantiate a new connection for each request. However, when not using proxy, it will simply keep the connection and use the keep alive feature. I've also checked reqwest and apparently, that library does not have an issue and keeps the proxied connection alive.
I've written two small functions to test demonstrate it:

const SLEEP_TIME: Duration = Duration::from_secs(2);

fn test_ureq() {
    let agent = ureq::AgentBuilder::new()
        .proxy(ureq::Proxy::new("socks5://127.0.0.1:10818").unwrap())
        .build();
    for _ in 0..100 {
        println!("{}", agent.get("https://api.ipify.org/").call().unwrap().into_string().unwrap());
        thread::sleep(SLEEP_TIME);
    }
}

fn test_reqwest() {
    let client = reqwest::blocking::ClientBuilder::new()
        .proxy(reqwest::Proxy::all("socks5://127.0.0.1:10818").unwrap())
        .build()
        .unwrap();
    for _ in 0..100 {
        println!("{}", client.get("https://api.ipify.org/").send().unwrap().text().unwrap());
        thread::sleep(SLEEP_TIME);
    }
}

You can check it with wireshark to see that it instantiates a new connection for each request. Tested with reqwest 0.11.24 and ureq 2.9.4.

@algesten
Copy link
Owner

algesten commented Feb 1, 2024

Hi @HirbodBehnam, welcome to ureq!

Thanks for reporting this. Must be something about the connection pooling that isn't happening under socks5.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants