首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >WCF客户端代理引发的TimeoutException

WCF客户端代理引发的TimeoutException
EN

Stack Overflow用户
提问于 2011-03-24 17:14:59
回答 2查看 4.4K关注 0票数 3

我的问题与WCF不时抛出的System.TimeoutException有关:

System.TimeoutException:在分配的00:00:00超时内,打开的操作没有完成。分配给此操作的时间可能是较长超时的一部分。-> System.TimeoutException:在建立到net.tcp://192.168.1.100:50000/TabletSvc/的传输会话时,在00:00之后打开超时。分配给此操作的时间可能是较长超时的一部分。--> System.TimeoutException:连接到net.tcp://192.168.1.100:50000/TabletSvc/在00:00之后超时。对一个可用地址()中的0进行了连接尝试。检查通道的RemoteAddress,并验证此端点的DNS记录是否与有效的IP地址相对应。分配给此操作的时间可能是较长超时的一部分。

随机行为的可能原因是什么?

WCF服务托管到运行在Windows .NET SP2上的一个SP2应用程序中。应用程序为托管在不同机器上的同一服务创建客户端代理。一个重要的方面是服务正在使用reliableSession和serviceThrottling。这些机器通过WiFi连接进行通信。

客户端和服务位于同一个应用程序中的单独线程上。从这个角度来看,他们并不相互依赖。不应该有锁。

我使用ping检查了机器之间的WiFi连接,它看起来很好。下一步将是设置一个网络监视器,但由于它们是生产机器,这可能不会很快发生。

我考虑将maxConcurrentSessions和maxConcurrentInstances都提高到50,但没有时间测试它。这是基于这样的想法:应用程序可能耗尽了资源,或者达到了影响托管服务的极限。

如前所述,客户端代理有时无法打开连接。一分钟后的第二次尝试通常会成功。

以下是客户端和服务配置:

代码语言:javascript
运行
复制
<system.serviceModel>
<client>
  <endpoint name="TabletSvcEndpoint" address="net.tcp://localhost:50000/TabletSvc/" binding="netTcpBinding" bindingConfiguration="TabletSvcBinding" contract="ITabletSvc">
   <identity>
    <dns value="localhost" />
   </identity>
  </endpoint>
</client>

<services>
 <service behaviorConfiguration="TabletSvcBehavior" name="TabletSvc">
   <endpoint name="TabletSvcEndpoint" address="" binding="netTcpBinding" bindingConfiguration="TabletSvcBinding" contract="ITabletSvc">
    <identity>
     <dns value="localhost" />
    </identity>
   </endpoint>
   <host>
    <baseAddresses>
     <add baseAddress="net.tcp://localhost:50000/TabletSvc/" />
        </baseAddresses>
   </host>
 </service>
</services>

<bindings>
 <netTcpBinding>
   <binding name="TabletSvcBinding" receiveTimeout="00:30:00" sendTimeout="00:00:30" closeTimeout="00:00:05" openTimeout="00:00:05" transactionFlow="false" transferMode="Buffered" transactionProtocol="OleTransactions" hostNameComparisonMode="StrongWildcard" listenBacklog="10" maxBufferPoolSize="524288" maxBufferSize="6553600" maxConnections="10" maxReceivedMessageSize="6553600">
    <readerQuotas maxDepth="32" maxStringContentLength="819200" maxArrayLength="163840" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
    <reliableSession inactivityTimeout="00:01:00" ordered="true" enabled="true" />
    <security mode="None" />
  </binding>
 </netTcpBinding>
</bindings>

<behaviors>
 <serviceBehaviors>
  <behavior name="TabletSvcBehavior">
   <serviceDebug includeExceptionDetailInFaults="true" />
   <serviceThrottling maxConcurrentSessions="10" maxConcurrentInstances="10" maxConcurrentCalls="100" />
  </behavior>
 </serviceBehaviors>
</behaviors>

<diagnostics performanceCounters="Off" wmiProviderEnabled="False" >
  <messageLogging maxMessagesToLog="250" logEntireMessage="true" logMessagesAtServiceLevel="true" logMalformedMessages="true" logMessagesAtTransportLevel="true" />
</diagnostics>
</system.serviceModel>

下面是异常的堆栈跟踪:

代码语言:javascript
运行
复制
10:20:18.3125 ClientChannel: Opening
10:20:48.8437 ClientChannel: Faulted
10:20:48.8593 Error: System.TimeoutException: The open operation did not complete within the allotted timeout of 00:00:00. The time allotted to this operation may have been a portion of a longer timeout. ---> System.TimeoutException: Open timed out after 00:00:00 while establishing a transport session to net.tcp://192.168.1.100:50000/TabletSvc/. The time allotted to this operation may have been a portion of a longer timeout. ---> System.TimeoutException: Connecting to via net.tcp://192.168.1.100:50000/TabletSvc/ timed out after 00:00:00. Connection attempts were made to 0 of 1 available addresses (). Check the RemoteAddress of your channel and verify that the DNS records for this endpoint correspond to valid IP Addresses. The time allotted to this operation may have been a portion of a longer timeout.
   at System.ServiceModel.Channels.SocketConnectionInitiator.CreateTimeoutException(Uri uri, TimeSpan timeout, IPAddress[] addresses, Int32 invalidAddressCount, SocketException innerException)
   at System.ServiceModel.Channels.SocketConnectionInitiator.Connect(Uri uri, TimeSpan timeout)
   at System.ServiceModel.Channels.BufferedConnectionInitiator.Connect(Uri uri, TimeSpan timeout)
   at System.ServiceModel.Channels.TracingConnectionInitiator.Connect(Uri uri, TimeSpan timeout)
   at System.ServiceModel.Channels.ConnectionPoolHelper.EstablishConnection(TimeSpan timeout)
   --- End of inner exception stack trace ---
   at System.ServiceModel.Channels.ConnectionPoolHelper.EstablishConnection(TimeSpan timeout)
   at System.ServiceModel.Channels.ClientFramingDuplexSessionChannel.OnOpen(TimeSpan timeout)
   --- End of inner exception stack trace ---

Server stack trace: 
   at System.ServiceModel.Channels.ClientFramingDuplexSessionChannel.OnOpen(TimeSpan timeout)
   at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
   at System.ServiceModel.Channels.ReliableChannelBinder`1.ChannelSynchronizer.SyncWaiter.TryGetChannel()
   at System.ServiceModel.Channels.ReliableChannelBinder`1.ChannelSynchronizer.SyncWaiter.TryWait(TChannel& channel)
   at System.ServiceModel.Channels.ReliableChannelBinder`1.ChannelSynchronizer.TryGetChannel(Boolean canGetChannel, Boolean canCauseFault, TimeSpan timeout, MaskingMode maskingMode, TChannel& channel)
   at System.ServiceModel.Channels.ReliableChannelBinder`1.Send(Message message, TimeSpan timeout, MaskingMode maskingMode)
   at System.ServiceModel.Channels.SendReceiveReliableRequestor.OnRequest(Message request, TimeSpan timeout, Boolean last)
   at System.ServiceModel.Channels.ReliableRequestor.Request(TimeSpan timeout)
   at System.ServiceModel.Channels.ClientReliableSession.Open(TimeSpan timeout)
   at System.ServiceModel.Channels.ClientReliableDuplexSessionChannel.OnOpen(TimeSpan timeout)
   at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
   at System.ServiceModel.Channels.ServiceChannel.OnOpen(TimeSpan timeout)
   at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
   at System.ServiceModel.Channels.ServiceChannel.CallOpenOnce.System.ServiceModel.Channels.ServiceChannel.ICallOnce.Call(ServiceChannel channel, TimeSpan timeout)
   at System.ServiceModel.Channels.ServiceChannel.CallOnceManager.CallOnce(TimeSpan timeout, CallOnceManager cascade)
   at System.ServiceModel.Channels.ServiceChannel.EnsureOpened(TimeSpan timeout)
   at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
   at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs)
   at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
   at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)

Exception rethrown at [0]: 
   at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
   at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
EN

回答 2

Stack Overflow用户

发布于 2012-07-19 07:51:42

我也有过这个问题。我解决了这个问题,将"Localhost“替换为"127.0.0.1”。

票数 1
EN

Stack Overflow用户

发布于 2014-09-16 23:59:56

运行在Windows SP2上的Windows NET应用程序

注意:对于,允许通过网络同时连接的其他计算机的最大数量为10台。此限制包括、所有传输、和资源共享协议的组合。对于Windows家庭版,允许通过网络同时连接的其他计算机的最大数量为五台。

Microsoft KB

还可以将其添加到app/web.config中。

代码语言:javascript
运行
复制
<system.net>
   <connectionManagement>
     <add address="*" maxconnection="5000" />
   </connectionManagement>
</system.net> 

微软从未打算让XP中的网络栈处理这么多连接.

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/5422932

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档