在使用netMessagingBinding连接到Service Bus端点时,需要有关配置HTTP代理的帮助。 我通过代理服务器访问Internet。当我尝试通过Service Bus端点连接到Azure上的辅助角色上托管的WCF服务时,我得到应用程序无法连接到远程端点的异常。当我通过直接互联网访问做同样的事情时,一切都很完美。
答案 0 :(得分:4)
代理服务器可能很棘手,具体取决于代理类型。尝试更改web.config / app.config的设置以启用代理支持:
自动检测:
<system.net>
<defaultProxy enabled="true" useDefaultCredentials="true" />
</system.net>
定义代理网址:
<system.net>
<defaultProxy enabled="true" useDefaultCredentials="true" />
<proxy autoDetect="True" proxyaddress="http://..."/>
</defaultProxy>
</system.net>
自定义凭据:
<appSettings>
<add key="ProxyUser" value="" />
<add key="ProxyPassword" value="" />
<add key="ProxyDomain" value="" />
<add key="ProxyUrl" value="" />
</appSettings>
<system.net>
<defaultProxy enabled="true">
<module type="CustomProxyCredentials.ProxyBridge, CustomProxyCredentials"/>
</defaultProxy>
</system.net>
namespace CustomProxyCredentials
{
public class ProxyBridge : IWebProxy
{
public ICredentials Credentials
{
get { return new NetworkCredential(ConfigurationManager.AppSettings["ProxyUser"], ConfigurationManager.AppSettings["ProxyPassword"], ConfigurationManager.AppSettings["ProxyDomain"]); }
set { }
}
public Uri GetProxy(Uri destination)
{
return new Uri(ConfigurationManager.AppSettings["ProxyUrl"]);
}
public bool IsBypassed(Uri host)
{
return false;
}
}
}
连接模式:
Microsoft.ServiceBus.ServiceBusEnvironment.SystemConnectivity.Mode = Microsoft.ServiceBus.ConnectivityMode.Http;
无论如何,配置应该足以使其正常工作。