{"id":106,"date":"2006-04-20T16:40:55","date_gmt":"2006-04-20T23:40:55","guid":{"rendered":"http:\/\/kennyw.com\/indigo\/106"},"modified":"2006-04-20T16:40:55","modified_gmt":"2006-04-20T23:40:55","slug":"configuration-http-proxies-in-wcf","status":"publish","type":"post","link":"https:\/\/kennyw.com\/?p=106","title":{"rendered":"Configuration Http Proxies in WCF"},"content":{"rendered":"<p>When using Http, <a href=\"http:\/\/kennyw.com\/indigo\/54\">proxy configuration madness<\/a> is a fact of life. If misconfigured, you can wind up trying to decipher obtuse <a href=\"http:\/\/kennyw.com\/indigo\/54\">502 (Bad Gateway)<\/a> and 504 (Gateway Timeout) errors.<\/p>\n<p>Fortunately there are a number of binding settings available in WCF to control your Http proxy usage. These settings are available directly on <code class=\"classname\">BasicHttpBinding<\/code> and <code class=\"classname\">WsHttpBinding<\/code> (as well as on <code class=\"classname\">HttpTransportBindingElement<\/code> when you are using a <code class=\"classname\">CustomBinding<\/code>).<\/p>\n<ul>\n<li><code class=\"keyword\">public bool<\/code> <code>UseDefaultWebProxy<\/code> (default == true): if set to true, will use the global value HttpWebRequest.DefaultProxy as your proxy. HttpWebRequest.DefaultProxy is controllable through System.Net config, and defaults to using the system proxy settings (i.e. when you see in your Internet Explorer properties).<\/li>\n<p><\/p>\n<li><code class=\"keyword\">public<\/code> <code class=\"classname\">Uri<\/code> <code>ProxyAddress<\/code> (default == null): If you want to specify a proxy directly you can set a proxy Uri directly here. To ensure no proxy is used you can specify \u00e2\u20ac\u0153null\u00e2\u20ac\u009d here. In both cases be sure to set UseDefaultWebProxy = false as well.<\/li>\n<p><\/p>\n<li><code class=\"keyword\">public bool<\/code> <code>BypassProxyOnLocal<\/code> (default == false): used in conjunction with ProxyAddress for when you specify a proxy. If you want &#8220;local&#8221; addresses (i.e. addresses on your intranet) to connect directly without using the proxy, set this value to <code class=\"keyword\">true<\/code>.<\/li>\n<p><\/p>\n<li><code class=\"keyword\">public<\/code> <code class=\"classname\">HttpProxyCredentialType HttpTransportSecurity<\/code><code>.ProxyCredentialType<\/code> (default == None): Specifies the authentication mode used with your Http proxy.  For custom bindings the equivalent setting is <code class=\"keyword\">public<\/code> <code class=\"classname\">AuthenticationSchemes<\/code> <code>ProxyAuthenticationScheme<\/code> (default == Anonymous) on <code class=\"classname\">HttpTransportBindingElement<\/code>.  For proxy authentication we will obtain the credential using the shared WCF provisioning framework (SecurityTokenProvider, etc).  We simply pass in the proxy address (rather than the target address) for acquiring these credentials.<\/li>\n<\/ul>\n<p>One last note about proxies: if you see a 502 or a 504 error returned to your client, then your client is using a proxy server. If this was not your intention, you can disable the server by setting <code>UseDefaultWebProxy<\/code> to <code class=\"keyword\">false<\/code>, and using the default ProxyAddress of <code class=\"keyword\">null<\/code>.  The other possibility is that your proxy is misconfigured and you can use the above settings to rectify that situation \ud83d\ude42<\/p>\n","protected":false},"excerpt":{"rendered":"<p>When using Http, proxy configuration madness is a fact of life. If misconfigured, you can wind up trying to decipher obtuse 502 (Bad Gateway) and 504 (Gateway Timeout) errors. Fortunately there are a number of binding settings available in WCF to control your Http proxy usage. These settings are available directly on BasicHttpBinding and WsHttpBinding [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11],"tags":[],"class_list":["post-106","post","type-post","status-publish","format-standard","hentry","category-indigo"],"_links":{"self":[{"href":"https:\/\/kennyw.com\/index.php?rest_route=\/wp\/v2\/posts\/106","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kennyw.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kennyw.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kennyw.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/kennyw.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=106"}],"version-history":[{"count":0,"href":"https:\/\/kennyw.com\/index.php?rest_route=\/wp\/v2\/posts\/106\/revisions"}],"wp:attachment":[{"href":"https:\/\/kennyw.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=106"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kennyw.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=106"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kennyw.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=106"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}