我有一个WCF服务,我用C#写的,它传递给调用者(一个C#WPF应用程序)实例化对象的集合。但是,如果我返回的集合具有太多对象,那么在大约10秒后,客户端调用会失败,并且会出现泛型异常(本身包含一系列通用内部异常)。这里是异常和内部异常:由于太多数据传递WCF服务调用失败?
{“,而接收到http://myserver/MyAppService/MyAppService.svc HTTP响应时发生错误这可能是由于 服务端点不使用HTTP协议绑定这可能 也可因。 HTTP请求上下文被服务器 中止(可能由于服务关闭)。请参阅服务器日志以获取更多 详细信息。“}
{”底层连接已关闭:接收方发生意外错误。“}
{“无法从传输连接读取数据:现有连接被远程主机强制关闭“}
{”一个现有的连接被强行关闭远程主机“}
的问题是100%reproduceable和肯定是涉及到集合的大小,而不是内容。我知道这一点,因为如果我将单个集合分解为多个较小的集合并将它们一次一个地传递回来,它就可以正常工作。只有当他们在一起并且收集到很大时,这才是一个问题。
我试着将客户端的app.config
文件中的maxReceivedMessageSize
属性增加到2147483647,但错误仍然存在。也尝试增加超时时间,但没有影响。以下是app.config
文件中的属性。我试着增加几乎每个号码下面2147483647,试图改变maxBufferPoolSize
为0,但没有运气:
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_iMyAppService"
closeTimeout="01:00:00" openTimeout="01:00:00"
receiveTimeout="01:00:00" sendTimeout="01:00:00"
allowCookies="false" bypassProxyOnLocal="false"
hostNameComparisonMode="StrongWildcard"
maxBufferSize="2147483647" maxBufferPoolSize="524288"
maxReceivedMessageSize="2147483647"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas
maxDepth="32" maxStringContentLength="8192"
maxArrayLength="16384" maxBytesPerRead="4096"
maxNameTableCharCount="16384" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
<wsHttpBinding>
<binding name="WSHttpBinding_iMyAppService"
closeTimeout="00:01:00" openTimeout="00:01:00"
receiveTimeout="00:10:00" sendTimeout="00:01:00"
bypassProxyOnLocal="false" transactionFlow="false"
hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="524288" maxReceivedMessageSize="2147483647"
messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
allowCookies="false">
<readerQuotas
maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<reliableSession ordered="true" inactivityTimeout="00:10:00"
enabled="false" />
<security mode="Message">
<transport clientCredentialType="Windows" proxyCredentialType="None"
realm="" />
<message clientCredentialType="Windows" negotiateServiceCredential="true"
algorithmSuite="Default" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint name="CurrencyConvertorSoap"
address="http://www.webservicex.net/CurrencyConvertor.asmx"
binding="basicHttpBinding"
bindingConfiguration="CurrencyConvertorSoap"
contract="CurrencyConverterService.CurrencyConvertorSoap" />
<endpoint name="CurrencyConvertorSoap12"
address="http://www.webservicex.net/CurrencyConvertor.asmx"
binding="customBinding"
bindingConfiguration="CurrencyConvertorSoap12"
contract="CurrencyConverterService.CurrencyConvertorSoap" />
<endpoint name="WSHttpBinding_iMyAppService"
address="http://myserver/MyAppService/MyAppService.svc"
binding="wsHttpBinding"
bindingConfiguration="WSHttpBinding_iMyAppService"
contract="MyAppService.iMyAppService" >
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint name="BasicHttpBinding_iMyAppService"
address="http://myserver/MyAppService/MyAppService.svc"
binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_iMyAppService"
contract="MyAppService.iMyAppService" />
</client>
还有什么更好的改变或添加,使这项工作?
谢谢!
该死的......当我看到你的回复时,我确实充满希望,但不幸的是,除非我没有做对。但我将此添加到我的app.config: <行为NAME = “Behaviors.EndpointBehavior”> endpointBehaviors> ,然后这对我端点行:behaviorConfiguration =“Behaviors.EndpointBehavior”但是,再次......没有工作不幸。同样的错误。感谢您的帮助。 –
Nullqwerty
2012-02-17 20:01:52
我不在我的电脑上,但我非常确定您需要在主机*和*客户端上进行设置?你有没有尝试过(这与@ felan的设置是一样的)。 – 2012-02-17 20:09:04
我尝试了Felan的建议,但那并不能解决它。我试图将maxitemsinobjectgraph的行为添加到服务器端web.config中,但这并没有实现。我无法将Felan添加到服务器端,虽然因为web.config没有这些选项,所以我不知道该把它放在哪里。 – Nullqwerty 2012-02-17 20:38:09