현재 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 섹션 전체를 게시한다면, 이것에 대해 밝혀 줄 수도 있습니다. –