我使用Xamarin开发服务器-客户端应用程序。我使用WCF将数据从服务器发送到客户端。有时还会发生超时异常。
我猜这是服务器连接速度慢的问题。通过快速的Wi-Fi,3g,4g是没有问题的。但如果连接速度低于3g,有时会发生超时。
我诊断了与WireShark的连接,它显示next when timeout (见图

)
请帮我解决这个问题。
发布于 2014-03-13 14:47:46
创建绑定时,可以指定超时和读取器配额。因此,您必须将超时跨度提高到适当的值。你可以在代码中或者通过配置文件来实现。
通过代码,您可以这样做
var binding = new NetNamedPipeBinding()
{
OpenTimeout = TimeSpan.MaxValue,
CloseTimeout = TimeSpan.MaxValue,
SendTimeout = TimeSpan.MaxValue,
ReceiveTimeout = TimeSpan.MaxValue,
ReaderQuotas = { MaxStringContentLength = 2147483647, MaxBytesPerRead = 2147483647, MaxArrayLength = 2147483647 },
MaxBufferSize = 6553500,
MaxReceivedMessageSize = 6553500
};通过配置文件,你可以这样做
<system.serviceModel>
<bindings>
<netTcpBinding>
<binding name="longTimeoutBinding"
receiveTimeout="00:10:00" sendTimeout="00:10:00">
<security mode="None"/>
</binding>
</netTcpBinding>
</bindings>
<services>
<service name="longTimeoutService"
behaviorConfiguration="longTimeoutBehavior">
<endpoint address="net.tcp://localhost/longtimeout/"
binding="netTcpBinding" bindingConfiguration="longTimeoutBinding" />
</service>
....https://stackoverflow.com/questions/22370945
复制相似问题