我遇到类似的错误: Azure Worker Role with HTTP input endpoint on port 8732 with HTTP 405 Error
我在MSDN上问了这个问题,但还没有回答: http://social.msdn.microsoft.com/Forums/en-US/windowsazuredevelopment/thread/6e9c84be-f39a-4da9-953e-a82f98afea54
问题是我无法使用Http Input端点测试多个Worker Role实例。当我在Azure模拟器上启动它时,我必须将HostnameComparsionMode设置为Exact,以便进行适当的http预留。但是,WCF端点与LB和HostnameComparsionMode = Exact的行为很奇怪(请参阅guomingliwcf.blogspot.com/2009/08/wcf-load-balance-error-http-405-method.html)
有没有人知道如何使用Http输入测试Azure模拟器中的WorkerRoles?
我重现问题的解决方案: https://www.dropbox.com/s/378oaqotdp0axen/HttpRolesTest.zip
更新 我正在使用以下代码启动服务主机
public override void Run()
{
// This is a sample worker implementation. Replace with your logic.
Trace.WriteLine("WorkerRole entry point called", "Information");
var endpoint = RoleEnvironment.CurrentRoleInstance.InstanceEndpoints.First().Value;
var ub = new UriBuilder();
ub.Host = endpoint.IPEndpoint.Address.ToString();
ub.Port = endpoint.IPEndpoint.Port;
ub.Scheme = "http";
ub.Path = "Service";
var host = new ServiceHost(typeof (Service), ub.Uri);
host.AddDefaultEndpoints();
host.Description.Behaviors.Add(new ServiceMetadataBehavior() {HttpGetEnabled = true});
host.Description.Behaviors.Add(new OverrideWCFAddressFilterServiceBehavior());
foreach (var e in host.Description.Endpoints)
{
((BasicHttpBinding)e.Binding).HostNameComparisonMode = HostNameComparisonMode.Exact;
}
host.Open();
foreach(var e in host.Description.Endpoints)
{
Trace.WriteLine("Host listening on " + e.ListenUri.ToString());
}
while (true)
{
Thread.Sleep(10000);
Trace.WriteLine("Working", "Information");
}
}
根据HostNameComparisonMode,我得到以下行为:
更新2
问题已在Allen Chen的msdn论坛上得到解答。