これと同様のエラーが発生しています: Azure Worker Role with HTTP input endpoint on port 8732 with HTTP 405 Error
MSDN で質問しましたが、まだ回答がありません 。
問題は、Http 入力エンドポイントを使用して Worker Role の複数のインスタンスをテストできないことです。Azure Emulator でそれらを開始するときは、適切な http 予約を行うために HostnameComparsionMode を Exact に設定する必要があります。ただし、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 に応じて、次の動作が得られます。
- Weak/StrongWildcard: 例外 System.ServiceModel.AddressAlreadyInUseException: HTTP は URL http://+を登録できませんでした:
- 正確: 405 MethodNotAllowed (ロード バランサー経由で wsdl にアクセスする場合)
更新 2
Allen Chen が msdn フォーラムで質問に回答しました。