現在、WCFサービスとC#基本Winformアプリケーションで再生しています。どちらも別のサーバーにあります。私は、C#アプリケーションがWCFを使用して他のサーバーからファイルを取得しようとしています。ここではWCFのコードだ:WCFがストリームを返すときにクライアントが終了しました
public Stream GetData(string fileName)
{
string filePath;
FileStream file = null;
try
{
// Stuff
file = File.OpenRead(Path.Combine(filePath, fileName));
file.Position = 0L;
return (Stream)file;
}
catch (Exception ex)
{
// Trace stuff
return Stream.Null;
}
}
、これは動作契約です:
[OperationContract]
Stream GetData(string fileName);
これは、クライアントの設定ファイルです:
<system.serviceModel>
<bindings>
<netTcpBinding>
<binding name="NetTcpBindingEndpoint" transferMode="Streamed" closeTimeout ="10:00:00" openTimeout="10:00:00" sendTimeout="10:00:00" receiveTimeout ="10:00:00" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
<security mode="None" />
</binding>
</netTcpBinding>
</bindings>
<client>
<endpoint address="net.tcp://SERVER/UpdaterUtilsWCF" binding="netTcpBinding"
bindingConfiguration="NetTcpBindingEndpoint" contract="UpdaterUtilsWCF.IUpdaterUtilsWCF"
name="NetTcpBindingEndpoint">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
</client>
</system.serviceModel>
、これはWCFの設定ファイルです:
<system.serviceModel>
<bindings>
<netTcpBinding>
<binding name="TCPBinding_IDataService" openTimeout="10:00:00"
closeTimeout="10:00:00"
sendTimeout="10:00:00"
receiveTimeout="10:00:00"
maxBufferPoolSize="2147483647"
maxBufferSize="2147483647"
maxReceivedMessageSize="2147483647"
transferMode="Streamed">
<security mode="None" />
</binding>
</netTcpBinding>
</bindings>
<services>
<service name="UpdaterWCF.UpdaterUtilsWCF">
<endpoint address="" binding="netTcpBinding" bindingConfiguration="TCPBinding_IDataService"
name="NetTcpBindingEndpoint" contract="UpdaterWCF.IUpdaterUtilsWCF">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexTcpBinding" bindingConfiguration=""
name="MexTcpBindingEndpoint" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="net.tcp://SERVER/UpdaterUtilsWCF" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="">
<serviceThrottling maxConcurrentCalls="100" maxConcurrentInstances="2147483647" maxConcurrentSessions="200" />
<dataContractSerializer maxItemsInObjectGraph="2147483646"/>
<serviceMetadata httpGetEnabled="false" httpsGetEnabled="false" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
最大同時呼び出し、インスタンス、およびセッションは、WCF構成ファイルで最大に設定されています。
これは、クライアント・アプリケーションのコードです:
using (Stream stream = WCFClient.GetData(textBox1.Text))
{
// stuff
}
私はアプリケーションを実行すると、それはクライアント側(またはWCF側)でクラッシュが、ストリームは、クライアントアプリケーションに渡されたとき。 WCFのコードをトレースし、呼び出しが行われ、WCFの最後に戻りコードが呼び出されます。 (400キロバイト)エラーはすぐにコールした後に表示され、ファイルが非常に小さいここでエラーです:
System.ServiceModel.CommunicationException: 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 '10:00:00'. System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags) at System.ServiceModel.Channels.SocketConnection.ReadCore(Byte[] buffer, Int32 offset, Int32 size, TimeSpan timeout, Boolean closing)
これで私を助けてください。
- EDITED I'vが、これは通常の構成で問題となっている、私の経験では、両方のアプリを
とバッファサイズのため、さらにはすべての同時バッファ値とクォータのためにすべての最大値を試してみました:
これは私が私の答えを見つけたところです。それでも同じエラーがあります。 – Alexandre
@Alexandre、あなたがクライアントとサーバーの両方のsystem.serviceModelセクション全体を投稿した場合は、これについて少し気をつけてください。 –