-
Notifications
You must be signed in to change notification settings - Fork 558
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
How to set Proxy Address for Http & Https bindings #1592
Comments
I don't think custom proxy address is currently supported. The default proxy is used. Does it block your scenario? |
Yes. We have a corporate proxy that is blocking the requests and we have to set the proxy address & credentials (not default) in order to get pass it. Is there a way to get around this limitation? |
It's supported to set a non default credential, see the code example https://github.com/dotnet/wcf/blob/master/src/System.Private.ServiceModel/tests/Scenarios/Security/TransportSecurity/Negotiate/NegotiateStream_Http_Tests.4.1.0.cs#L121 The default proxy should work for the machines on your corporate. Could you give a try? |
Thanks @hongdai. I tried to configure it like the example you provided but it did not work. I keep getting: The remote server returned an unexpected response: (407) Proxy Authentication Required We have always had to specify the proxy address in other apps, but I do not see a way of doing it here. For HttpClient which is what WCF uses under the covers we would need to set the Proxy property:
but I do not find an extensibility point to provide the proxy settings. |
@epignosisx, can you verify that using HttpClientHandler in that way works for you in your network environment and you can make successful calls? Due to backwards compatibility requirements, some of the properties on HttpClientHandler on some platforms are noop's. If this works for you, then we can add the WCF proxy api to our contract surface and wire the property through. Depending on timing, we might be able to get this done for the 1.1 RTM release (but there's no guarantee so this isn't a hard commitment), otherwise you could use a development build of WCF. |
I can confirm that assigning an implementation of It would be great if it can make it to 1.1 RTM. This is an impediment for anyone behind a corporate proxy. We had to resort to crafting the SOAP envelope manually. I can help test a build. |
@epignosisx you can provide us an a sample how to set HttpClientHandler to WCF client? |
Hi folks. I noticed this got moved from 2.0 to future. This is a pretty big blocker for any customer behind an authenticated proxy. I'm surprised you haven't heard more about this issue from other people. Is there any chance of considering putting this back on 2.0? |
Hi @epignosisx this issue is still in 2.0.0 milestone. We will try but depending on how much cycles @mconnew has as the door for 2.0.0 is closing very fast. |
Great to hear! Some further ideas on the issue: It would be great if an application could participate in the creation of the HttpClients. This would not only give us a chance to configure the HttpClientHandler's proxy, but also add additional DelegatingHandlers that we may use. For example to skip the network call and return canned responses (great for mocking external services). |
@epignosisx , the limitation we have is we can't add an api which isn't available on the full framework. On the full framework, we use HttpWebRequest so it would be quite a lot of work to make a delegating handler work with HttpWebRequest in a reliable clean way. |
Can't argue with the points you brought up. I didn't account for the Full Framework or UWP. It is definitely tricky to accommodate this feature when there are 3 different ways of making HTTP calls. I'll open the issue. For now I'm happy with having the ability to specify proxy settings somehow. |
@epignosisx, proxy support has been checked in. It has only had basic manual validation at this point but you should be able to pick up a build with support from the myget dev feeds tomorrow. This only supports running on windows at the moment. |
Move the *nix support to post 2.0. @epignosisx please let us know if this is important to you. |
Thanks folks for working on this. Linux support is not a priority for me. |
@epignosisx, were you able to verify this works for you on windows? |
Hi all. I have problem with configure proxy for http binding in .net core 2.0. var binding = new BasicHttpBinding(); After call service i have Exception: "When using a non-null Proxy, the WindowsProxyUsePolicy property must be set to WindowsProxyUsePolicy.UseCustomProxy." But i can`t set this property. In .net core 1.0 this code work correctly. How i can do it? Maybe i use it wrong? |
I have investigation about this problem. Important nootice - I talk about windows. I think problem in ServiceModelHttpMessageHandler used in WCF for Win. It wrapper for WinHttpHandler. Key difference between it and HttpClientHandler used in Unix build - it not set WindowsProxyUsePolicy.UseCustomProxy in case use proxy. |
Hi, I have a strange problem with BasicHttpBinding and proxy settings that is probably related to this issue. The situation in our company is that we used to have corporate proxy and then at some point they removed it. We removed proxy from all windows settings and everything works as expected except WCF calls. WCF somehow still wants to use proxy even if there is no proxy configured in windows (also cleared automatic proxy detection from windows). Opening urls in browser works, using HttpClient from aspnet core works, only WCF calls throw exception: "WinHttpException: The server name or address could not be resolved", I have verified in wireshark that there is request for DNS resolve of old proxy, even if it is not configured anywhere. Then I tried to set UseDefaultWebProxy on BasicHttpBinding to false and then I get following error: "InvalidOperationException: When using a non-null Proxy, the WindowsProxyUsePolicy property must be set to WindowsProxyUsePolicy.UseCustomProxy." I should also mention that when using VPN to access my workplace connections succeed. Do you have a hint why is this happening and why only WCF calls require old proxy even if it is not configured anywhere? |
@zminic, HttpClient in .Net Core doesn't use WinINet which picks up its proxy settings from the same place as you configure IE/Edge proxy settings. It uses WinHTTP instead which maintains its own proxy settings. From an administrative command prompt execute the command |
@mconnew Thanks a lot! It worked. Didn't know that .Net core uses different proxy settings. |
The fix for broken proxy usage will be in the preview 1 release for .Net Core 2.1 |
Based on this thread, to proxy to Fiddler on Windows 10, I used these commands as admin:
On Linux, is http_proxy environment variable supported? I guess I'll find out. |
@ctaggart, in your use case WCF is configuring HttpClientHandler to use the default proxy. The behavior of what that means on Linux is a question for the dotnet/corefx repo as we don't do anything special there. |
I'm trying to set a proxy address and credentials to an Https binding but I have not find a way. Do you have some documentation or can you provide a code snippet on how to do it?
The text was updated successfully, but these errors were encountered: