3

私の質問は、WCF によって時々スローされる System.TimeoutException に関連しています。

System.TimeoutException: 割り当てられたタイムアウト 00:00:00 内にオープン操作が完了しませんでした。この操作に割り当てられた時間は、より長いタイムアウトの一部であった可能性があります。---> System.TimeoutException: net.tcp://192.168.1.100:50000/TabletSvc/ へのトランスポート セッションを確立中に、00:00:00 後にオープンがタイムアウトしました。この操作に割り当てられた時間は、より長いタイムアウトの一部であった可能性があります。---> System.TimeoutException: net.tcp://192.168.1.100:50000/TabletSvc/ 経由での接続が 00:00:00 後にタイムアウトしました。1 つの使用可能なアドレス () のうちの 0 に対して接続試行が行われました。チャネルの RemoteAddress を調べて、このエンドポイントの DNS レコードが有効な IP アドレスに対応していることを確認してください。この操作に割り当てられた時間は、より長いタイムアウトの一部であった可能性があります。

ランダムな動作の考えられる原因は何ですか?

WCF サービスは、Windows XP SP2 で実行される .NET アプリケーションにホストされます。アプリケーションは、別のマシンでホストされている同じサービスへのクライアント プロキシを作成します。重要な側面の 1 つは、サービスがreliableSession と serviceThrottling を使用していることです。マシンは WiFi 接続を介して通信しています。

クライアントとサービスは、同じアプリケーション内の別のスレッドにあります。この観点から、それらは互いに依存していません。ロックがあってはなりません。

ping を使用してマシン間の WiFi 接続を確認しましたが、問題ないようです。次のステップは、ネットワーク モニターを配置することですが、それらは運用マシンであるため、すぐには実現しない可能性があります。

maxConcurrentSessions と maxConcurrentInstances の両方を 50 に増やすことを考えましたが、テストする時間がありませんでした。これは、アプリケーションがリソースを使い果たしているか、ホストされているサービスに影響を与える制限に達している可能性があるという考えに基づいています.

前述したように、クライアント プロキシが接続を開くのに失敗することがあります。1 分後に 2 回目の試行を行うと、通常は成功します。

クライアントとサービスの構成は次のとおりです。

<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>

例外のスタック トレースは次のとおりです。

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)
4

2 に答える 2

1

Windows XP SP2 で実行される NET アプリケーション

注: Windows XP Professional の場合、ネットワーク経由で同時に接続できる他のコンピューターの最大数は 10 です。この制限には、すべてのトランスポートとリソース共有プロトコルの組み合わせが含まれます。Windows XP Home Edition の場合、ネットワーク経由で同時に接続できる他のコンピューターの最大数は 5 台です。

マイクロソフト KB

これも app/web.config に追加してください

<system.net>
   <connectionManagement>
     <add address="*" maxconnection="5000" />
   </connectionManagement>
</system.net> 

Microsoft は、XP のネットワーク スタックが非常に多くの接続を処理することを意図していませんでした...

于 2014-09-16T23:59:56.657 に答える
1

私もこの問題を抱えていました。「Localhost」を「127.0.0.1」に置き換えて解決しました。

于 2012-07-19T07:51:42.780 に答える