2011-09-01 13 views
3

ServiceHostオブジェクトでホストされているWCFサービスがあります。 ServiceHostは、AzureワーカーロールのOnStartメソッドで作成されます。ここでは、コードは次のようになります。1分以上の呼び出しでServiceBusのWCFサービスが失敗する

 ServiceBusEnvironment.SystemConnectivity.Mode = ConnectivityMode.Http; 

     Uri baseAddress = ServiceBusEnvironment.CreateServiceUri("http", "my_sb", "SimpleService"); 

     host = new ServiceHost(typeof(SimpleService1.Service1), baseAddress); 

     BasicHttpRelayBinding binding = new BasicHttpRelayBinding(EndToEndBasicHttpSecurityMode.None, RelayClientAuthenticationType.None); 
     binding.OpenTimeout = new TimeSpan(1, 1, 0); 
     binding.ReceiveTimeout = new TimeSpan(1, 10, 0); 
     binding.SendTimeout = new TimeSpan(1, 10, 0); 
     binding.MaxReceivedMessageSize = 73400320; 
     XmlDictionaryReaderQuotas readerQuotas = new XmlDictionaryReaderQuotas(); 
     readerQuotas.MaxArrayLength = 73400320; 
     binding.ReaderQuotas = readerQuotas; 

     TransportClientEndpointBehavior sharedSecretServiceBusCredential = new TransportClientEndpointBehavior(); 
     sharedSecretServiceBusCredential.CredentialType = TransportClientCredentialType.SharedSecret; 

     sharedSecretServiceBusCredential.Credentials.SharedSecret.IssuerName = "owner"; 
     sharedSecretServiceBusCredential.Credentials.SharedSecret.IssuerSecret = "blablablabla=="; 


     ContractDescription contractDescription = ContractDescription.GetContract(typeof(SimpleService1.IService1), typeof(SimpleService1.Service1)); 
     ServiceEndpoint serviceEndPoint = new ServiceEndpoint(contractDescription); 
     serviceEndPoint.Address = new EndpointAddress(baseAddress); 
     serviceEndPoint.Binding = binding; 

     IEndpointBehavior serviceRegistrySettings = new ServiceRegistrySettings(DiscoveryType.Public); 

     serviceEndPoint.Behaviors.Add(serviceRegistrySettings); 
     serviceEndPoint.Behaviors.Add(sharedSecretServiceBusCredential); 


     host.Description.Endpoints.Add(serviceEndPoint); 

     try 
     { 

      host.Open(); 

     } 

     catch (Exception ex) 
     { 

      Trace.WriteLine(ex.Message, "Error"); 

      throw; 

     } 

     Trace.WriteLine("SimpleService1 running..."); 

と、クライアント側のバインディングの構成は以下のとおりです。

 <basicHttpBinding> 
      <binding name="FileTransferBinding" closeTimeout="00:10:00" openTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:10:00" maxReceivedMessageSize="73400320"> 
      <readerQuotas maxArrayLength="73400320"/> 
      <security mode="None"/> 
      </binding> 
     </basicHttpBinding> 

<endpoint address="http://my_sb.servicebus.windows.net/simpleservice" binding="basicHttpBinding" bindingConfiguration="FileTransferBinding" contract="Service1reference.IService1" name="FileTransferBinding" behaviorConfiguration="sbBehavior"/> 

問題は、サービスへの1つの呼び出しがより長くかかる場合ということです1分、クライアントはこの例外を受け取ります。

The content type application/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 

私がnetTcpRelayBindingへのバインディングを変更すると、すべて正常に動作します。

答えて

3

これは、接続が1分間以上アイドル状態になっているとWindows Azureロードバランサが接続を切断するためです。

あなたの最善の策は、WCFコールバックを使用することです。これにより、サーバーからクライアントへの呼び出しが実行され、長時間実行された操作が完了したことが通知されます。これを行う方法の詳細については、このブログを参照してください[WCF Callbacks

関連する問題