0

我遇到了与此类似的错误: 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 我得到以下行为:

  • 弱/强通配符:异常 System.ServiceModel.AddressAlreadyInUseException:HTTP 无法注册 URL http://+
  • 确切:通过负载均衡器访问 wsdl 时出现 405 MethodNotAllowed

更新 2

问题已由 Allen Chen 在 msdn 论坛上回答。

4

0 回答 0