Repository navigation
Closed
Description
Description
在 System.Net.Http.HttpConnectionPoolManager.SendAsync(HttpRequestMessage request, Boolean async, Boolean doRequestAuth, CancellationToken cancellationToken)
在 System.Net.Http.HttpConnectionHandler.SendAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
在 System.Net.Http.HttpMessageHandlerStage.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
在 System.Net.Http.Metrics.MetricsHandler.SendAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
在 System.Net.Http.HttpMessageHandlerStage.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
在 System.Net.Http.DiagnosticsHandler.<SendAsyncCore>d__10.MoveNext()
在 System.Runtime.CompilerServices.ConfiguredValueTaskAwaitable`1.ConfiguredValueTaskAwaiter.GetResult()
在 System.Net.Http.RedirectHandler.<SendAsync>d__4.MoveNext()
在 System.Net.Http.SocketsHttpHandler.<<SendAsync>g__CreateHandlerAndSendAsync|115_0>d.MoveNext()
在 System.Net.Http.HttpClient.<GetStringAsyncCore>d__41.MoveNext()
在 ConsoleApp1.Program.<Main>d__0.MoveNext() 在 C:\Users\ali\Desktop\ConsoleApp1\ConsoleApp1\Program.cs 中: 第 15 行
Only the 'http', 'https', 'socks4', 'socks4a' and 'socks5' schemes are allowed for proxies.
Reproduction Steps
using var handler = new SocketsHttpHandler();
handler.Proxy = new WebProxy("socks5h://username:password@ip:port");
using HttpClient client = new HttpClient(handler);
var response = await client.GetStringAsync("http://ifconfig.me/ip");Expected behavior
normal request
Actual behavior
throw an exception
Only the 'http', 'https', 'socks4', 'socks4a' and 'socks5' schemes are allowed for proxies.
Regression?
No response
Known Workarounds
No response
Configuration
No response
Other information
No response
Reacted by Copilot
Activity
dotnet-policy-service commentedon Jan 15, 2026
Tagging subscribers to this area: @karelz, @dotnet/ncl
See info in area-owners.md if you want to be subscribed.
MihaZupan commentedon Jan 15, 2026
https://en.wikipedia.org/wiki/SOCKS
TIL socks5h is a thing.
I think it'd be fine to add with the same behavior as our socks5 support, but I would not change our socks5 logic to resolve addresses locally. We can treat both the same and always forward the host to the proxy, the user always has the option to do the name resolution locally before making the request.
wfurt commentedon Jan 15, 2026
Is that something we want to do for 11 @MihaZupan ? Or set it to Future and do it opportunistically?
MihaZupan commentedon Jan 15, 2026
Normally I'd say Future, but since Copilot one-shot the whole change in #123218 I don't see much harm in adding it in 11.
itbencn commentedon Jan 17, 2026
Great, I have seen the corresponding PR modification records, but it seems that it will take a long time to officially use this feature at present Is there any alternative way to use SOCKS5H in the .NET 10 distribution
MihaZupan commentedon Jan 17, 2026
Just change the Url to
socks5instead. They behave the same in our implementation.itbencn commentedon Jan 17, 2026
I tried to change
SOCKS5HtoSOCKS5inNET10, but encountered an error inI also tried to change
SOCKS5HtoSOCKS5through thelibcurllibrary, but it still reported an errorproxy handshake errorIn summary, it cannot be directly modified and seems to be related to the proxy server or protocol.
I don't mind providing a testable
SOCKS5Hproxy, but it requires configuring an IP whitelist.MihaZupan commentedon Jan 17, 2026
If you can't connect with either .NET or Curl it's likely an issue with your proxy instead.
The spec says error 2 is
X'02' connection not allowed by ruleset, I'd check what the server thinks about your connections.itbencn commentedon Feb 11, 2026
@MihaZupan
I just used the
NET11 preview SDKfor testingFound using
new WebProxy("socks5h://username:password@ip:port")Return0x02when in modeBut use
handler.Proxy.Credetials=new NetworkCredentials ("username", "password");Request normally when displaying configured credentialsThe problem exists for both SOCKS5 and SOCKS5H
May I ask what caused this
MihaZupan commentedon Feb 11, 2026
Simply the fact that we never look at the
UserInfoof the proxy url you set viaWebProxy, we only look at theCredentials.itbencn commentedon Feb 11, 2026
I can understand it as
new WebProxy ("socks5h://username:password@ip:port")is only responsible for parsing the proxy address part and ignores the authentication information carriedThe behavior I thought before was that the authentication information carried would be processed together during parsing
itbencn commentedon Feb 14, 2026
new WebProxy ("socks5h://username:password@ip:port")will the authentication information carried in the URI string not be automatically assigned to thehandler.Proxy.Cedetialsobject ?MihaZupan commentedon Feb 14, 2026
No, you have to set the Credentials yourself.
We could consider changing that (extract it from the Uri), but this has been the behavior for a long time.
itbencn commentedon Feb 14, 2026
It is more reasonable to automatically assign authentication information to
Credentialswhen it is carried in the URI, otherwise the way Uri string parsing is very limited. Do I need to initiate a new issue?