You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

DotNetBrowser是否支持SOCKS5认证?代理配置示例适配咨询

Does DotNetBrowser Support SOCKS5 Authentication?

Absolutely, DotNetBrowser does support SOCKS5 proxies with authentication—the HTTP(S) proxy example you referenced works for that protocol family, but SOCKS5 requires using a dedicated proxy type in your configuration setup.

Here's how to implement authenticated SOCKS5 proxy correctly:

  • Instead of the generic proxy setup for HTTP(S), use the Socks5Proxy class, which is explicitly built for SOCKS5 connections and includes a Credentials property to pass your username and password.
  • Wrap this proxy configuration into ProxySettings and attach it to your engine's initialization options.

Working Code Example

using DotNetBrowser.Browser;
using DotNetBrowser.Engine;
using DotNetBrowser.Net.Proxy;
using DotNetBrowser.Net;

namespace Socks5ProxyDemo
{
    class Program
    {
        static void Main(string[] args)
        {
            // Build engine options with authenticated SOCKS5 proxy
            EngineOptions engineOptions = new EngineOptions.Builder()
                .Proxy(new ProxySettings.Builder()
                    // Apply this proxy to all outgoing requests
                    .AddProxyRule("*", new Socks5Proxy("your-socks5-host", 1080)
                    {
                        Credentials = new NetworkCredentials("proxy-username", "proxy-password")
                    })
                    .Build())
                .Build();

            using (IEngine engine = EngineFactory.Create(engineOptions))
            using (IBrowser browser = engine.CreateBrowser())
            {
                // Test navigation to verify proxy functionality
                browser.Navigation.LoadUrl("https://example.com").Wait();
                string pageTitle = browser.MainFrame.Title;
                System.Console.WriteLine($"Page title: {pageTitle}");
            }
        }
    }
}

Key Notes

  • The AddProxyRule("*", ...) applies the SOCKS5 proxy to all URLs. You can adjust the rule pattern (e.g., "*.example.com" for specific domains) if you need granular proxy routing.
  • This functionality is available in all recent stable releases of DotNetBrowser, so ensure you're running a compatible version.
  • For dynamic proxy changes at runtime, you can modify the ProxySettings via the Engine.Network.Proxy.Settings property after the engine has been initialized.

内容的提问来源于stack exchange,提问作者Stoica Nicusor

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.22 10:09:26