3

入力パラメーターに応じて大量のデータを返すことができる WCF サービスがあります。

サービスは私のマシンで ServiceHost 実行可能ファイルとして実行されており、現在テストのために WCF テスト クライアントを使用しています。

これが私のホスト構成です:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <system.serviceModel>
        <bindings>
            <netTcpBinding>
                <binding name="NetTcpBinding_ExchangeRepository"
                         closeTimeout="00:01:00" openTimeout="00:01:00"
                         receiveTimeout="00:10:00" sendTimeout="00:10:00"
                         transactionFlow="false" transferMode="Streamed"
                         transactionProtocol="OleTransactions" hostNameComparisonMode="StrongWildcard"
                         listenBacklog="500"    maxBufferPoolSize="2147483646"
                         maxBufferSize="2147483646" maxConnections="500"
                         maxReceivedMessageSize="2147483647"  >
                    <readerQuotas
                        maxDepth="32" maxStringContentLength="2147483647" maxArrayLength="2147483647"
                        maxBytesPerRead="4096" maxNameTableCharCount="2147483647" />
                    <reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false" />
                    <security mode="None">
                    </security>
                </binding>          
            </netTcpBinding>
        </bindings>         
        <services>          
            <service name="MyCompany.MyApplication.DataServices.ExchangeRepository" 
                     behaviorConfiguration="MyCompany.MyApplication.DataServicesBehavior">
                <endpoint address ="" 
                          binding="netTcpBinding" 
                          contract="MyCompany.MyApplication.DataServices.IExchangeRepository"
                          bindingConfiguration="NetTcpBinding_ExchangeRepository" 
                          behaviorConfiguration="MyCompany.MyApplication.EndpointBehavior">
                    <identity>
                        <dns value="localhost"/>
                    </identity>
                </endpoint>
                <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
                <host>
                    <baseAddresses>
                        <add baseAddress = "net.tcp://localhost:8896/ExchangeRepository/" />
                        <add baseAddress = "http://localhost:8895/ExchangeRepository/" />
                    </baseAddresses>
                </host>
            </service>
        </services>         
        <behaviors>
            <serviceBehaviors>
                <behavior name="MyCompany.MyApplication.DataServicesBehavior">
                    <dataContractSerializer maxItemsInObjectGraph="2147483646"/>
                    <serviceMetadata httpGetEnabled="True"/>
                    <serviceDebug includeExceptionDetailInFaults="True" />
                </behavior>
            </serviceBehaviors>
            <endpointBehaviors>
                <behavior name="MyCompany.MyApplication.EndpointBehavior">
                    <dataContractSerializer maxItemsInObjectGraph="2147483646"/>
                </behavior>
            </endpointBehaviors>
        </behaviors>    
    </system.serviceModel>
</configuration>

これが私のクライアント設定です:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <system.serviceModel>
        <behaviors>
            <endpointBehaviors>
                <behavior name="endpointBehaviour">
                    <dataContractSerializer maxItemsInObjectGraph="2147483647" />
                </behavior>
            </endpointBehaviors>
        </behaviors>
        <bindings>
            <netTcpBinding>
                <binding name="NetTcpBinding_IExchangeRepository" closeTimeout="00:10:00"
                    openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
                    transactionFlow="false" transferMode="Streamed" transactionProtocol="OleTransactions"
                    hostNameComparisonMode="StrongWildcard" listenBacklog="10"
                    maxBufferPoolSize="524288" maxBufferSize="2147483647" maxConnections="10"
                    maxReceivedMessageSize="2147483647">
                    <readerQuotas maxDepth="32" maxStringContentLength="2147483647"
                        maxArrayLength="2147483647" maxBytesPerRead="4096" maxNameTableCharCount="2147483647" />
                    <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:8896/ExchangeRepository/"
                behaviorConfiguration="endpointBehaviour" binding="netTcpBinding"
                bindingConfiguration="NetTcpBinding_IExchangeRepository" contract="IExchangeRepository"
                name="NetTcpBinding_IExchangeRepository">
                <identity>
                    <dns value="localhost" />
                </identity>
            </endpoint>
        </client>
    </system.serviceModel>
</configuration>

そして、ここに私が得ているエラーがあります:

The socket connection has been disposed.

Server stack trace: 
   at System.ServiceModel.Channels.SocketConnection.ThrowIfNotOpen()
   at System.ServiceModel.Channels.SocketConnection.Read(Byte[] buffer, Int32 offset, Int32 size, TimeSpan timeout)
   at System.ServiceModel.Channels.DelegatingConnection.Read(Byte[] buffer, Int32 offset, Int32 size, TimeSpan timeout)
   at System.ServiceModel.Channels.PreReadConnection.Read(Byte[] buffer, Int32 offset, Int32 size, TimeSpan timeout)
   at System.ServiceModel.Channels.SingletonConnectionReader.SingletonInputConnectionStream.ReadCore(Byte[] buffer, Int32 offset, Int32 count)
   at System.ServiceModel.Channels.SingletonConnectionReader.SingletonInputConnectionStream.Read(Byte[] buffer, Int32 offset, Int32 count)
   at System.ServiceModel.Channels.MaxMessageSizeStream.Read(Byte[] buffer, Int32 offset, Int32 count)
   at System.ServiceModel.Channels.SingletonConnectionReader.Close(TimeSpan timeout)
   at System.ServiceModel.Channels.SingletonConnectionReader.SingletonInputConnectionStream.Close()
   at System.ServiceModel.Channels.DelegatingStream.Close()
   at System.Xml.XmlBufferReader.Close()
   at System.Xml.XmlBaseReader.Close()
   at System.Xml.XmlBinaryReader.Close()
   at System.Xml.XmlReader.Dispose(Boolean disposing)
   at System.Xml.XmlReader.Dispose()
   at System.ServiceModel.Dispatcher.OperationFormatter.DeserializeBodyContents(Message message, Object[] parameters, Boolean isRequest)
   at System.ServiceModel.Dispatcher.OperationFormatter.DeserializeReply(Message message, Object[] parameters)
   at System.ServiceModel.Dispatcher.ProxyOperationRuntime.AfterReply(ProxyRpc& rpc)
   at System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc)
   at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
   at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
   at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)

Exception rethrown at [0]: 
   at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
   at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
   at IExchangeRepository.SearchExchangeRequest(String AccountNumber, Int32 StatusCode, Int32 StartDate, Int32 EndDate)
   at ExchangeRepositoryClient.SearchExchangeRequest(String AccountNumber, Int32 StatusCode, Int32 StartDate, Int32 EndDate)

Inner Exception:
The socket connection has been disposed.
Object name: 'System.ServiceModel.Channels.SocketConnection'.

このエラーは、返されるデータに一定数以上のレコードがある場合に発生します。データが少ないため、すべてが期待どおりに機能しています。

これを解決する方法について何か提案はありますか?

4

1 に答える 1

1

まあ、それはすべて愚かなデータの問題によって引き起こされました。エラーメッセージはまったく役に立ちません。トレースを有効にすると、実際の例外を確認できました。ありがとう、EkoostikMartin!

于 2012-06-22T20:29:19.613 に答える