C# WCF服务失败,30秒内超时1小时
我在本地使用WCF服务来计算一些信息,这是C#,并返回数据。 我返回的数据是一个浮动列表,共有4个浮动。每个浮动列表包含400个项目,每个集合中有180个这些列表。因此,第4个C# WCF服务失败,30秒内超时1小时,c#,wcf,service,timeout,C#,Wcf,Service,Timeout,我在本地使用WCF服务来计算一些信息,这是C#,并返回数据。 我返回的数据是一个浮动列表,共有4个浮动。每个浮动列表包含400个项目,每个集合中有180个这些列表。因此,第4个列表 我最初有一个空间不足错误,然后将大小更新为最大2000000字节 <?xml version="1.0" encoding="utf-8"?> <configuration> <system.serviceModel> <bindings> &l
列表
我最初有一个空间不足错误,然后将大小更新为最大2000000字节
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.serviceModel>
<bindings>
<netTcpBinding>
<binding name="NetTcpBinding_IExternalBallistics" closeTimeout="01:10:00"
openTimeout="01:10:00" receiveTimeout="01:10:00" sendTimeout="01:10:00"
transactionFlow="false" transferMode="Buffered" transactionProtocol="OleTransactions"
hostNameComparisonMode="StrongWildcard" listenBacklog="10"
maxBufferPoolSize="2000000" maxBufferSize="2000000" maxConnections="10"
maxReceivedMessageSize="2000000">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<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:6100/ExternalBallistics"
binding="netTcpBinding" bindingConfiguration="NetTcpBinding_IExternalBallistics"
contract="IExternalBallistics" name="NetTcpBinding_IExternalBallistics" />
</client>
</system.serviceModel>
</configuration>
我还将超时设置为1小时10分钟
我得到的错误是
套接字连接已中止。这可能是由于处理消息时出错、远程主机超过接收超时或基础网络资源问题造成的。本地套接字超时为“01:09:59.9770000”。
现在,此超时在30秒内发生。我有一个正在运行的单元测试,该服务可以正确执行所有操作,并且回复包含有效数据,但是当它返回此回复时,我总是会收到此错误
我一直在搜索,但我无法得到任何解决的答案,因为我看到的答案只是通知我增加缓冲区/超时。尽管报告为超时异常,但这可能是另一个问题 请尝试设置maxItemsInObjectGraph以确保可以发送大型对象图
<serviceBehaviors>
<behavior name="MyBehavior">
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
<serviceMetadata />
</behavior>
</serviceBehaviors>
</behaviors>
只需点击以下链接,希望对您有所帮助:
正如@Tim在他的评论中所建议的,这可能是因为服务器在30秒后无法与客户机通信。客户端可能已关闭其连接
确保客户端上的绑定设置与服务器上的绑定设置匹配。特别是,确保客户端的
receiveTimeout
值与服务器的sendTimeout
类似,您在服务本身中没有遇到任何错误-当服务向客户端发送响应时会发生这种情况?是的,这肯定是答案。在unity3D中使用解决方案时,为了给解决方案添加更多内容,我不能为该服务使用配置。所以我需要在WCF主机代码中定义所有这些。因此,我只是从代码中拉出了foreach循环,我还必须将其应用到客户端。类似的方法,但您可以从channelFactory获得操作说明。
<serviceBehaviors>
<behavior name="MyBehavior">
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
<serviceMetadata />
</behavior>
</serviceBehaviors>
</behaviors>