【发布时间】:2011-10-20 09:23:45
【问题描述】:
我在本地使用 WCF 服务来计算一些信息,这是 C#,并返回数据。
我返回的数据是浮动列表List<List< float>> 的列表,总共有 4 个。每个浮动列表包含 400 个项目,每个集合中有 180 个这些列表。所以List<List<float>>的4个
我最初遇到空间不足错误,然后将大小更新为最大 2,000,000 字节。
<?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>
我还在我的主机中手动更新了这些值。
private void InitializeServiceHost()
{
if (_serviceHost != null)
{
_serviceHost.Close();
}
Uri address = new Uri("net.tcp://localhost:6100/ExternalBallistics");
NetTcpBinding binding = new NetTcpBinding(SecurityMode.None);
binding.MaxReceivedMessageSize = 2000000;
binding.MaxBufferSize = 2000000;
binding.MaxBufferPoolSize = 2000000;
binding.CloseTimeout = new TimeSpan(1, 10, 0);
binding.OpenTimeout = new TimeSpan(1, 10, 0);
binding.ReceiveTimeout = new TimeSpan(1, 10, 0);
binding.SendTimeout = new TimeSpan(1, 10, 0);
_serviceHost = new ServiceHost(typeof(ExternalBallisticsImpl), address);
_serviceHost.Description.Behaviors.Add(GetMetadataBehavior());
_serviceHost.CloseTimeout = new TimeSpan(1, 10, 0);
_serviceHost.OpenTimeout = new TimeSpan(1, 10, 0);
_serviceHost.AddServiceEndpoint(typeof(IExternalBallistics), binding, address);
_serviceHost.AddServiceEndpoint(ServiceMetadataBehavior.MexContractName, MetadataExchangeBindings.CreateMexTcpBinding(), "mex");
_serviceHost.Open();
}
我还将超时设置为 1 小时 10 分钟。
我得到的错误是
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 '01:09:59.9770000'.
现在此超时发生在 30 秒内。我正在运行一个单元测试,并且服务正确执行所有操作,并且回复包含有效数据,但是当它返回此回复时,我总是收到此错误。
我一直在搜索,但我找不到任何可以解决的答案,因为我看到的答案只是告诉我增加我拥有的缓冲区/超时。
【问题讨论】:
-
您在服务本身中没有遇到任何错误 - 当服务向客户端发送响应时会发生这种情况?