问题
We are using the Azure Service Bus Relay for connecting our on-premise WCF services to our Azure-hosted Web Role. When we upgrade our on-premise WCF services, we always get a 502 Bad Gateway response from our first few requests through the Azure Service Bus, after the service bus host has re-established itself with the relay (we don't get the "No service is hosted at the specified address." since the service is hosted properly).
After a given timeout period - it seems the error disappears and WCF requests are handled properly through the relay. We are using basicHttpRelayBinding with HTTP Keep-Alives disabled (to prevent CommunicationExceptions
).
Here is the error message we capture during the WCF requests to the relay from the web role:
System.ServiceModel.ProtocolException: The content type application/soap+xml; charset=utf-8 of the response message does not match the content type of the binding (text/xml; charset=utf-8). If using a custom encoder, be sure that the IsContentTypeSupported method is implemented properly. T he first 550 bytes of the response were...
<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing">
<s:Header>
<a:Action s:mustUnderstand="1">http://schemas.microsoft.com/netservices/2009/05/servicebus/relay/FaultAction</a:Action>
</s:Header>
<s:Body>
<s:Fault>
<s:Code>
<s:Value>s:Receiver</s:Value>
<s:Subcode>
<s:Value>s:Receiver</s:Value>
</s:Subcode>
</s:Code>
<s:Reason>
<s:Text xml:lang="en-US">50200: Bad Gateway.TrackingId:8bd21714-ae0f-41b5-b810-851b59a345fb_28,TimeStamp:5/29/2012 8:27:14 PM</s:Text>
</s:Reason>
</s:Fault>
</s:Body>
</s:Envelope>
We are currently trying disabling the default web proxy in the WCF Bindings (via useDefaultWebProxy=false
), but are wondering if others have seen this same HTTP 502 behavior with the Azure Service Bus and how to fix it.
回答1:
I have seen such problem when connecting an on-premise WCF services to Azure-hosted Web Role and these are mostly caused by having proxy in on-premise network. In any enterprise IT environment all machines network setting is set to use Proxy server either Auto detect or if you have multiple proxy server you actually set which one to choose. When WCF service connect outside world it goes through same proxy settings and that actually changes the dynamics of connecting it and introduce the behavior.
By setting UseDefaultWebProxy to false you are asking web service to not use machine specific proxy and use user setting which is part of your web service configuration.
I think you are on good track to disable the web proxy and see how it works. Also try using Service Trace Viewer for Viewing Correlated Traces and Troubleshooting here.
来源:https://stackoverflow.com/questions/10807134/azure-service-bus-relay-502-bad-gateway-after-service-restart