Skip to content

Performance issue with SOCKS5 proxy #68

Description

@Mbaspfd

Hi, I noticed a possible performance issue in HttpCloak when using a SOCKS5 proxy.

I compared two simple GET requests to:

https://checkip.amazonaws.com/

Both requests use the same SOCKS5 proxy

The regular C# HttpClient request completes much faster, while the same request through HttpCloak is around 4 times slower.

This issue happens only with a SOCKS5 proxy. With an HTTP proxy, I don't see the same performance problem.

Example code C#:

const string url = "https://checkip.amazonaws.com/";

var sw = Stopwatch.StartNew();

using var client = new HttpClient(new HttpClientHandler
{
    Proxy = new WebProxy("socks5://niceproxy.io:17521")
    {
        Credentials = new NetworkCredential("login", "password")
    },
    UseProxy = true
});

var response = await client.GetAsync(url);

sw.Stop();

Console.WriteLine($"HttpClient: Status Code: {(int)response.StatusCode} | {sw.ElapsedMilliseconds} ms");

sw.Restart();

using var session = new Session(
    preset: "chrome-latest",
    proxy: "socks5://login:password@niceproxy.io:17521");

var response2 = await session.GetAsync(url);

sw.Stop();

Console.WriteLine($"HttpCloak: Status Code: {response2.StatusCode} | {sw.ElapsedMilliseconds} ms");
Console.ReadKey();

Example result with the same Socks5 proxy:

HttpClient: Status Code: 200 | 1614 ms
HttpCloak: Status Code: 200 | 6679 ms

So in this case, HttpCloak is approximately 4x slower with the same SOCKS5 proxy, while HTTP proxies works work normally.

Example result with the same Http proxy:

HttpClient: Status Code: 200 | 1639 ms
HttpCloak: Status Code: 200 | 1457 ms

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions