我有一个持续的WCF问题,我似乎无法解决。我有一个WCF Duplex发布者订阅架构。客户端是一个Windows窗体应用程序,该服务托管在Windows服务中。表单实现回调并使用受保护的代理类在通道出现故障时分配事件处理程序,以便客户端可以重新连接。
任何时候都有大约100个客户订阅。问题是某些客户端停止从服务接收消息。故障事件处理程序永远不会在客户端上触发,因此永远不会重新连接。我在服务器和客户端上启用了跟踪,并且服务器上的错误是一致的。它连续抛出大约5个异常。我无法确定服务抛出的原因。我认为我得到一个套接字超时“错误代码247c”,它是10060 tcp套接字超时的十六进制。可能导致什么?我猜这个错误不会让客户知道频道已经出现故障。我已检查端口5000是否已打开。没有防火墙问题.....请帮助。
以下是异常树中最后一个异常和最内层节点的跟踪视图:
<InnerException><ExceptionType>System.Net.Sockets.SocketException, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</ExceptionType><Message>A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond</Message><StackTrace> at System.ServiceModel.AsyncResult.End[TAsyncResult](IAsyncResult result)
at System.ServiceModel.Channels.SynchronizedMessageSource.SynchronizedAsyncResult`1.End(IAsyncResult result)
at System.ServiceModel.Channels.FramingDuplexSessionChannel.EndReceive(IAsyncResult result)
at System.ServiceModel.Channels.FramingDuplexSessionChannel.TryReceiveAsyncResult.OnReceive(IAsyncResult result)
at System.ServiceModel.Diagnostics.Utility.AsyncThunk.UnhandledExceptionFrame(IAsyncResult result)
at System.ServiceModel.AsyncResult.Complete(Boolean completedSynchronously)
at System.ServiceModel.Channels.SynchronizedMessageSource.SynchronizedAsyncResult`1.CompleteWithUnlock(Boolean synchronous, Exception exception)
at System.ServiceModel.Channels.SynchronizedMessageSource.ReceiveAsyncResult.OnReceiveComplete(Object state)
at System.ServiceModel.Channels.SessionConnectionReader.OnAsyncReadComplete(Object state)
at System.ServiceModel.Channels.StreamConnection.OnRead(IAsyncResult result)
at System.ServiceModel.Diagnostics.Utility.AsyncThunk.UnhandledExceptionFrame(IAsyncResult result)
at System.Net.LazyAsyncResult.Complete(IntPtr userToken)
at System.Net.LazyAsyncResult.ProtectedInvokeCallback(Object result, IntPtr userToken)
at System.Net.FixedSizeReader.ReadCallback(IAsyncResult transportResult)
at System.ServiceModel.AsyncResult.Complete(Boolean completedSynchronously)
at System.ServiceModel.Channels.ConnectionStream.ReadAsyncResult.OnAsyncReadComplete(Object state)
at System.ServiceModel.Channels.TracingConnection.TracingConnectionState.ExecuteCallback()
at System.ServiceModel.Channels.SocketConnection.FinishRead()
at System.ServiceModel.Channels.SocketConnection.AsyncReadCallback(Boolean haveResult, Int32 error, Int32 bytesRead)
at System.ServiceModel.Diagnostics.Utility.IOCompletionThunk.UnhandledExceptionFrame(UInt32 error, UInt32 bytesRead, NativeOverlapped* nativeOverlapped)
at System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* pOVERLAP)
</StackTrace><ExceptionString>System.Net.Sockets.SocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond</ExceptionString><NativeErrorCode>274C</NativeErrorCode></InnerException></InnerException></InnerException></Exception>
这是我的客户端app.config:
<system.serviceModel>
<diagnostics>
<messageLogging logEntireMessage="true"
maxMessagesToLog="1000"
logMessagesAtServiceLevel="true"
logMalformedMessages="true"
logMessagesAtTransportLevel="true" />
</diagnostics>
<bindings>
<netTcpBinding>
<binding name="netTCPEndPoint"
closeTimeout="10:00:00"
openTimeout="10:00:00"
receiveTimeout="10:00:00"
sendTimeout="10:00:00"
listenBacklog="300"
maxBufferPoolSize="1048576"
maxBufferSize="524288"
maxConnections="300"
maxReceivedMessageSize="524288">
<reliableSession inactivityTimeout="10:00:00" enabled="false" />
<security mode="Transport">
<transport clientCredentialType="Windows" protectionLevel="EncryptAndSign" />
<message clientCredentialType="Windows" />
</security>
</binding>
</netTcpBinding>
</bindings>
<client>
<endpoint address="net.tcp://ccccc.************:5000/ClientNotificationService/tcp"
binding="netTcpBinding" bindingConfiguration="netTCPEndPoint"
contract="NotificationService.ClientNotificationServiceService"
name="netTCPEndPoint">
<identity>
<userPrincipalName value="" />
</identity>
</endpoint>
</client>
</system.serviceModel>
这是我的服务app.config:
<bindings>
<netTcpBinding>
<binding name="BindingTimeout"
closeTimeout="10:00:00"
openTimeout="10:00:00"
receiveTimeout="10:00:00"
sendTimeout="10:00:00"
listenBacklog="1000"
maxBufferPoolSize="10485760"
maxBufferSize="5242880"
maxConnections="1000"
maxReceivedMessageSize="5242880">
<reliableSession inactivityTimeout="10:00:00" enabled="false" />
<security mode="Transport">
<transport clientCredentialType="Windows" protectionLevel="EncryptAndSign" />
<message clientCredentialType="Windows" />
</security>
</binding>
</netTcpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="NotificationService.ClientNotificationServiceBehavior">
<serviceThrottling maxConcurrentCalls="1000" maxConcurrentSessions="1000"
maxConcurrentInstances="1000" />
<serviceMetadata httpGetEnabled="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service behaviorConfiguration="NotificationService.ClientNotificationServiceBehavior"
name="NotificationService.ClientNotificationService">
<endpoint address="net.tcp://xxxx.*******:5000/ClientNotificationService/tcp"
binding="netTcpBinding" bindingConfiguration="BindingTimeout"
name="netTCPEndPoint" contract="NotificationService.IClientNotificationService">
<identity>
<userPrincipalName value="" />
<dns value="http://xxxx.*******" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" bindingConfiguration=""
name="mexEndPoint" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://xxxx.*******:3081/NotificationService/ClientNotificationService" />
</baseAddresses>
</host>
</service>
</services>
谢谢。