【发布时间】:2014-12-10 04:13:43
【问题描述】:
我在尝试将文件夹的所有文件发送到服务器然后将处理后的输出发送到 C# 控制台客户端时抛出以下异常..
以下是例外,
System.Net.WebException: The underlying connection was closed: An unexpected error occurred on a
receive. ---> System.IO.IOException: Unable to read data from the transport
connection: An existing connection was forcibly closed by the remote host. --->
System.Net.Sockets.SоcketException: An existing connection was forcibly closed by the remote host
аt System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
如果我处理与单个文件相同的文件,它可以正常工作。
以下是使用的绑定参数,
在服务器的 web.config 中:
<binding name="ExtendedMaxSize"
openTimeout="10:01:00"
receiveTimeout="10:10:00"
sendTimeout="10:01:00"
maxBufferPoolSize="2147483647"
maxReceivedMessageSize="2147483647"
messageEncoding="Text"
textEncoding="utf-8">
<readerQuotas maxDepth="64"
maxStringContentLength="2147483647"
maxArrayLength="2147483647"
maxBytesPerRead="8192"
maxNameTableCharCount="16384"/>
<security mode="None">
<transport clientCredentialType="None"/>
</security>
在客户端的 app.config 中:
<binding name="WSHttpBinding_InterfaceWCFServer1"
openTimeout="10:01:00"
receiveTimeout="10:10:00"
sendTimeout="10:01:00"
bypassProxyOnLocal="false"
transactionFlow="false"
hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="2147483647"
maxReceivedMessageSize="2147483647"
messageEncoding="Text"
textEncoding="utf-8"
useDefaultWebProxy="true"
allowCookies="false">
<readerQuotas maxDepth="64"
maxStringContentLength="2147483647"
maxArrayLength="2147483647"
maxBytesPerRead="8192"
maxNameTableCharCount="16384" />
<security mode="None">
<transport clientCredentialType="None"
proxyCredentialType="None"
realm="">
<extendedProtectionPolicy policyEnforcement="Never" />
</transport>
<message clientCredentialType="Windows"
negotiateServiceCredential="true"
algorithmSuite="Default"
establishSecurityContext="true" />
</security>
</binding>
我在笔记本电脑中使用 8 GB RAM,服务器和客户端都在同一台机器上。
在任务管理器中看到Processes 时,我发现 w3wp.exe 的使用量从 700 MB 到 6 GB,当使用量达到 95% 的限制时,我会抛出此异常,并且 @ 使用的内存987654325@ 减少到 700 mb 左右,然后再次为每个请求增加,直到达到大约 95% 的内存。所以此时我抛出了这个异常。
【问题讨论】:
-
下次正确格式化您的问题!