<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress/2.2.2" -->
<rss version="2.0" 
	xmlns:content="http://purl.org/rss/1.0/modules/content/">
<channel>
	<title>Comments on: 502 (Bad Gateway) and Http clients</title>
	<link>http://kennyw.com/indigo/54</link>
	<description>Kenny Wolf's Thoughts of the Moment</description>
	<pubDate>Thu, 08 Jan 2009 12:13:44 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.2.2</generator>

	<item>
		<title>By: Kenny</title>
		<link>http://kennyw.com/indigo/54#comment-34651</link>
		<author>Kenny</author>
		<pubDate>Fri, 09 Mar 2007 02:11:40 +0000</pubDate>
		<guid>http://kennyw.com/indigo/54#comment-34651</guid>
		<description>What account are each of these applications running as? It sounds like the domain account for the windows service does not have the correct proxy settings</description>
		<content:encoded><![CDATA[<p>What account are each of these applications running as? It sounds like the domain account for the windows service does not have the correct proxy settings</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Harvinder Bholowasia</title>
		<link>http://kennyw.com/indigo/54#comment-32081</link>
		<author>Harvinder Bholowasia</author>
		<pubDate>Sat, 24 Feb 2007 11:04:10 +0000</pubDate>
		<guid>http://kennyw.com/indigo/54#comment-32081</guid>
		<description>I am trying to get the Metadata of a service using MetadataExchangeClient, from a Self-Hosted (Windows Service) WCF service. I am getting the following error:-
System.InvalidOperationException was caught
  Message="Metadata contains a reference that cannot be resolved: 'http://harvinder-test.csfidc.com/Session40/SessionManagerAdmin.svc?xsd=xsd1'."
  Source="System.ServiceModel"
  StackTrace:
       at System.ServiceModel.Description.MetadataExchangeClient.MetadataRetriever.Retrieve(TimeoutHelper timeoutHelper)
       at System.ServiceModel.Description.MetadataExchangeClient.ResolveNext(ResolveCallState resolveCallState)
       at System.ServiceModel.Description.MetadataExchangeClient.ResolveNext(ResolveCallState resolveCallState)
       at System.ServiceModel.Description.MetadataExchangeClient.GetMetadata(MetadataRetriever retriever)
       at System.ServiceModel.Description.MetadataExchangeClient.GetMetadata(Uri address, MetadataExchangeClientMode mode)
       at Microsoft.ConnectedServices.MV.DebugService.SessionChannelFactory._getKerberosEndpoint(String server) in C:\MVInstall\Local\src\MVServer\Microsoft.ConnectedServices.MV.DebugService\SessionChannelFactory.cs:line 107

                The inner-exception is The remote server returned an error: (502) Bad Gateway. 

                The code that I used to get the Metadata is:-
        private static ServiceEndpoint _getKerberosEndpoint(string server)
        {
            string ssuffix = System.Configuration.ConfigurationManager.AppSettings["SessionManagerAdminAddressSuffix"];
            WSHttpBinding mexBinding = new WSHttpBinding(SecurityMode.None);
            mexBinding.MaxReceivedMessageSize = Int32.MaxValue;
            MetadataExchangeClient mexClient = new MetadataExchangeClient(mexBinding);
            mexClient.ResolveMetadataReferences = true;
            MetadataSet metadataSet = null;
            WsdlImporter importer = null;
            ServiceEndpoint endpointToReturn = null;

            //Get the ISessionMgrAdmin Metadata
            Uri wsdlUri = new Uri("http://" + server + "/" + ssuffix + "?wsdl");
            metadataSet = mexClient.GetMetadata(wsdlUri, MetadataExchangeClientMode.HttpGet);
            importer = new WsdlImporter(metadataSet);
            ServiceEndpointCollection secCollection = importer.ImportAllEndpoints();

            WSHttpBinding currentBinding = null;
            foreach (ServiceEndpoint ep in secCollection)
            {
                currentBinding = ep.Binding as WSHttpBinding;
                if (currentBinding == null &#124;&#124; currentBinding.Security.Message.ClientCredentialType != MessageCredentialType.Windows)
                    continue;
                endpointToReturn = ep;
                break;
            }

            return endpointToReturn;
        }

                But when I try to get the Metadata of the same service, using a ConsoleApplication (using the same piece of code, as in the Windows Service) â€“ I am able to retrieve the ServiceEndpoint correctly!!
                Can someone please tell me what might be going wrong?</description>
		<content:encoded><![CDATA[<p>I am trying to get the Metadata of a service using MetadataExchangeClient, from a Self-Hosted (Windows Service) WCF service. I am getting the following error:-<br />
System.InvalidOperationException was caught<br />
  Message=&#8221;Metadata contains a reference that cannot be resolved: &#8216;http://harvinder-test.csfidc.com/Session40/SessionManagerAdmin.svc?xsd=xsd1&#8242;.&#8221;<br />
  Source=&#8221;System.ServiceModel&#8221;<br />
  StackTrace:<br />
       at System.ServiceModel.Description.MetadataExchangeClient.MetadataRetriever.Retrieve(TimeoutHelper timeoutHelper)<br />
       at System.ServiceModel.Description.MetadataExchangeClient.ResolveNext(ResolveCallState resolveCallState)<br />
       at System.ServiceModel.Description.MetadataExchangeClient.ResolveNext(ResolveCallState resolveCallState)<br />
       at System.ServiceModel.Description.MetadataExchangeClient.GetMetadata(MetadataRetriever retriever)<br />
       at System.ServiceModel.Description.MetadataExchangeClient.GetMetadata(Uri address, MetadataExchangeClientMode mode)<br />
       at Microsoft.ConnectedServices.MV.DebugService.SessionChannelFactory._getKerberosEndpoint(String server) in C:\MVInstall\Local\src\MVServer\Microsoft.ConnectedServices.MV.DebugService\SessionChannelFactory.cs:line 107</p>
<p>                The inner-exception is The remote server returned an error: (502) Bad Gateway. </p>
<p>                The code that I used to get the Metadata is:-<br />
        private static ServiceEndpoint _getKerberosEndpoint(string server)<br />
        {<br />
            string ssuffix = System.Configuration.ConfigurationManager.AppSettings[&#8221;SessionManagerAdminAddressSuffix&#8221;];<br />
            WSHttpBinding mexBinding = new WSHttpBinding(SecurityMode.None);<br />
            mexBinding.MaxReceivedMessageSize = Int32.MaxValue;<br />
            MetadataExchangeClient mexClient = new MetadataExchangeClient(mexBinding);<br />
            mexClient.ResolveMetadataReferences = true;<br />
            MetadataSet metadataSet = null;<br />
            WsdlImporter importer = null;<br />
            ServiceEndpoint endpointToReturn = null;</p>
<p>            //Get the ISessionMgrAdmin Metadata<br />
            Uri wsdlUri = new Uri(&#8221;http://&#8221; + server + &#8220;/&#8221; + ssuffix + &#8220;?wsdl&#8221;);<br />
            metadataSet = mexClient.GetMetadata(wsdlUri, MetadataExchangeClientMode.HttpGet);<br />
            importer = new WsdlImporter(metadataSet);<br />
            ServiceEndpointCollection secCollection = importer.ImportAllEndpoints();</p>
<p>            WSHttpBinding currentBinding = null;<br />
            foreach (ServiceEndpoint ep in secCollection)<br />
            {<br />
                currentBinding = ep.Binding as WSHttpBinding;<br />
                if (currentBinding == null || currentBinding.Security.Message.ClientCredentialType != MessageCredentialType.Windows)<br />
                    continue;<br />
                endpointToReturn = ep;<br />
                break;<br />
            }</p>
<p>            return endpointToReturn;<br />
        }</p>
<p>                But when I try to get the Metadata of the same service, using a ConsoleApplication (using the same piece of code, as in the Windows Service) â€“ I am able to retrieve the ServiceEndpoint correctly!!<br />
                Can someone please tell me what might be going wrong?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: mattonsoftware.com : .NET Resources</title>
		<link>http://kennyw.com/indigo/54#comment-1073</link>
		<author>mattonsoftware.com : .NET Resources</author>
		<pubDate>Sat, 06 May 2006 08:33:34 +0000</pubDate>
		<guid>http://kennyw.com/indigo/54#comment-1073</guid>
		<description>[...]  [...]</description>
		<content:encoded><![CDATA[<p>[&#8230;]  [&#8230;]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: kennyw.com &#187; Blog Archive &#187; Configuration Http Proxies in WCF</title>
		<link>http://kennyw.com/indigo/54#comment-691</link>
		<author>kennyw.com &#187; Blog Archive &#187; Configuration Http Proxies in WCF</author>
		<pubDate>Thu, 20 Apr 2006 23:41:02 +0000</pubDate>
		<guid>http://kennyw.com/indigo/54#comment-691</guid>
		<description>[...] 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. [...]</description>
		<content:encoded><![CDATA[<p>[&#8230;] 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. [&#8230;]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Hao Xu</title>
		<link>http://kennyw.com/indigo/54#comment-50</link>
		<author>Hao Xu</author>
		<pubDate>Tue, 25 Oct 2005 22:59:29 +0000</pubDate>
		<guid>http://kennyw.com/indigo/54#comment-50</guid>
		<description>502 can also be due to the firewall if the server is running on the same machine. If the on-machine server is listening at a port blocked by the firewall, the proxy server won't be able to connect. It will ultimately time out after several failed TCP SYN packets and return 502 to client.</description>
		<content:encoded><![CDATA[<p>502 can also be due to the firewall if the server is running on the same machine. If the on-machine server is listening at a port blocked by the firewall, the proxy server won&#8217;t be able to connect. It will ultimately time out after several failed TCP SYN packets and return 502 to client.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Yasser Shohoud</title>
		<link>http://kennyw.com/indigo/54#comment-48</link>
		<author>Yasser Shohoud</author>
		<pubDate>Wed, 12 Oct 2005 17:43:13 +0000</pubDate>
		<guid>http://kennyw.com/indigo/54#comment-48</guid>
		<description>&lt;strong&gt;Meet the WCF Channel Model - Part 1&lt;/strong&gt;

For the past 5 months or so, Iâ€™ve been working on the WCF Core Communications team (with Kenny, Matt,...</description>
		<content:encoded><![CDATA[<p><strong>Meet the WCF Channel Model - Part 1</strong></p>
<p>For the past 5 months or so, Iâ€™ve been working on the WCF Core Communications team (with Kenny, Matt,&#8230;</p>
]]></content:encoded>
	</item>
</channel>
</rss>
