2011-08-04 10 views
4

WCFサービスをローカルで使用してC#で情報を計算しています。 私が返すデータは、浮動小数点リストList<List< float>>のリストです。これらの合計は4個です。フロートの各リストには400個のアイテムがあり、各コレクションに180個のリストがあります。したがって、List<List<float>>WCFサービスは、30秒で1時間のタイムアウトで失敗します。

私はもともと不十分なスペースエラーがあり、最大2,000,000バイトまでのサイズを更新しました。

<?xml version="1.0" encoding="utf-8"?> 
<configuration> 
<system.serviceModel> 
    <bindings> 
     <netTcpBinding> 
      <binding name="NetTcpBinding_IExternalBallistics" closeTimeout="01:10:00" 
       openTimeout="01:10:00" receiveTimeout="01:10:00" sendTimeout="01:10:00" 
       transactionFlow="false" transferMode="Buffered" transactionProtocol="OleTransactions" 
       hostNameComparisonMode="StrongWildcard" listenBacklog="10" 
       maxBufferPoolSize="2000000" maxBufferSize="2000000" maxConnections="10" 
       maxReceivedMessageSize="2000000"> 
       <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" 
        maxBytesPerRead="4096" maxNameTableCharCount="16384" /> 
       <reliableSession ordered="true" inactivityTimeout="00:10:00" 
        enabled="false" /> 
       <security mode="None"> 
        <transport clientCredentialType="Windows" protectionLevel="EncryptAndSign" /> 
        <message clientCredentialType="Windows" /> 
       </security> 
      </binding> 
     </netTcpBinding> 
    </bindings> 
    <client> 
     <endpoint address="net.tcp://localhost:6100/ExternalBallistics" 
      binding="netTcpBinding" bindingConfiguration="NetTcpBinding_IExternalBallistics" 
      contract="IExternalBallistics" name="NetTcpBinding_IExternalBallistics" /> 
    </client> 
</system.serviceModel> 
</configuration> 

また、これらの値を手動でホストで更新しました。

private void InitializeServiceHost() 
{ 
    if (_serviceHost != null) 
    { 
     _serviceHost.Close(); 
    } 

    Uri address = new Uri("net.tcp://localhost:6100/ExternalBallistics"); 
    NetTcpBinding binding = new NetTcpBinding(SecurityMode.None); 
    binding.MaxReceivedMessageSize = 2000000; 
    binding.MaxBufferSize = 2000000; 
    binding.MaxBufferPoolSize = 2000000; 
    binding.CloseTimeout = new TimeSpan(1, 10, 0); 
    binding.OpenTimeout = new TimeSpan(1, 10, 0); 
    binding.ReceiveTimeout = new TimeSpan(1, 10, 0); 
    binding.SendTimeout = new TimeSpan(1, 10, 0); 
    _serviceHost = new ServiceHost(typeof(ExternalBallisticsImpl), address); 
    _serviceHost.Description.Behaviors.Add(GetMetadataBehavior()); 
    _serviceHost.CloseTimeout = new TimeSpan(1, 10, 0); 
    _serviceHost.OpenTimeout = new TimeSpan(1, 10, 0); 
    _serviceHost.AddServiceEndpoint(typeof(IExternalBallistics), binding, address); 
    _serviceHost.AddServiceEndpoint(ServiceMetadataBehavior.MexContractName, MetadataExchangeBindings.CreateMexTcpBinding(), "mex"); 

    _serviceHost.Open(); 
} 

タイムアウトを1時間10分に設定しました。

私が手にエラーが The socket connection was aborted. This could be caused by an error processing your message or a receive timeout being exceeded by the remote host, or an underlying network resource issue. Local socket timeout was '01:09:59.9770000'.

今、このタイムアウトは30秒以内に発生しています。私はユニットテストを実行しており、サービスはすべて正しく行い、応答には有効なデータが含まれていますが、この返信を返すと常にこのエラーが発生します。

私は検索してきましたが、私が見たような解決方法はありません。私が持っているバッファ/タイムアウトを増やすように通知します。

+0

サービス自体にエラーが発生していません。これは、サービスがクライアントに応答を送信したときに発生しますか? – Tim

答えて

1

タイムアウト例外として報告されていますが、別の問題かもしれません。

大型オブジェクトグラフを送信できるようにmaxItemsInObjectGraphを設定してみますか。

<serviceBehaviors> 

    <behavior name="MyBehavior"> 

     <dataContractSerializer maxItemsInObjectGraph="2147483647"/> 

     <serviceMetadata /> 

    </behavior> 

    </serviceBehaviors> 

</behaviors> 

ちょうどそれが助けたい、次のリンクをたどる:

http://davybrion.com/blog/2008/09/wcf-and-large-amounts-of-data/

+0

はい、これは間違いなく答えでした。私がunity3Dで使用しているようにもう少し私のソリューションに追加するには、サービスの設定を使用することはできません。だから私はWCFホストコードでこれをすべて定義する必要がありました。だから、私はこのコードからforeachループを抜き出しただけです。http://social.msdn.microsoft.com/Forums/en-US/wcf/thread/12e09a40-df41-4bf7-8462-c40df68af3d5 私もこれを適用しなければなりませんでしたクライアントにも送信されます。同様のメソッドですが、channelFactoryから操作の説明を取得します。 – michael

1

@Timが彼のコメントで示唆したように、これは、サーバーができないの問題であるかもしれません〜30秒後にクライアントに話してください。クライアントが既に接続を終了している可能性があります。

クライアントのバインド設定がサーバーのバインド設定と一致していることを確認してください。特に、クライアントのreceiveTimeoutの値がサーバーのsendTimeoutに似ていることを確認してください。

関連する問題