当调用返回字符串“success”的方法时,WCF客户端在120秒后返回上述异常。来自服务器的日志显示它完全执行并在大约3分钟内完成。启用跟踪后,我看不到任何错误。 任何帮助将不胜感激由于类似问题的其他建议不幸没有帮助。谢谢!WCF超时太快&'连接意外关闭'异常
编辑 - 解决:原来,客户端正在使用Smoothwall过滤设备,两分钟后关闭连接。
例外:
System.ServiceModel.CommunicationException The underlying connection was closed: The connection was closed unexpectedly.
Stack Trace: at System.Net.HttpWebRequest.GetResponse()
at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
的InnerException:
System.Net.WebException The underlying connection was closed: The connection was closed unexpectedly.The underlying connection was closed: The connection was closed unexpectedly.
Stack Trace: at System.Net.HttpWebRequest.GetResponse()
at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
据我所看到的,绑定正确设置和超时超出120秒。这里的客户端绑定:
<bindings>
<customBinding>
<binding name="CustomBinding_IPHG" closeTimeout="00:05:00"
openTimeout="00:05:00" receiveTimeout="00:15:00" sendTimeout="00:15:00">
<security authenticationMode="SecureConversation" requireDerivedKeys="false">
<localClientSettings maxClockSkew="00:30:00" />
<localServiceSettings maxClockSkew="00:30:00" />
<secureConversationBootstrap authenticationMode="UserNameOverTransport">
<localClientSettings maxClockSkew="00:30:00" />
<localServiceSettings maxClockSkew="00:30:00" />
</secureConversationBootstrap>
</security>
<textMessageEncoding>
<readerQuotas maxStringContentLength="5242880" />
</textMessageEncoding>
<httpsTransport maxReceivedMessageSize="6553600" useDefaultWebProxy="true" />
</binding>
</customBinding>
</bindings>
<behaviors>
<endpointBehaviors>
<behavior name="commonBehaviour">
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
<clientCredentials>
<serviceCertificate>
<authentication certificateValidationMode="PeerOrChainTrust"/>
</serviceCertificate>
</clientCredentials>
</behavior>
</endpointBehaviors>
</behaviors>
这里的服务器绑定:
<bindings>
<customBinding>
<binding name="CommonBinding" closeTimeout="00:05:00" openTimeout="00:05:00" receiveTimeout="00:15:00" sendTimeout="00:15:00">
<transactionFlow />
<security authenticationMode="SecureConversation" requireDerivedKeys="false">
<secureConversationBootstrap authenticationMode="UserNameOverTransport">
<localServiceSettings maxClockSkew="00:30:00" />
<localClientSettings maxClockSkew="00:30:00" />
</secureConversationBootstrap>
<localServiceSettings maxClockSkew="00:30:00" />
<localClientSettings maxClockSkew="00:30:00" />
</security>
<textMessageEncoding>
<readerQuotas maxStringContentLength="41943040"/>
</textMessageEncoding>
<httpsTransport maxBufferSize="41943040" maxReceivedMessageSize="41943040" />
</binding>
</customBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="BehaviorRBS">
<serviceMetadata httpsGetEnabled="true" httpGetEnabled="false" />
<serviceDebug includeExceptionDetailInFaults="true" httpHelpPageEnabled="false" />
<dataContractSerializer maxItemsInObjectGraph="2147483647" />
<serviceCredentials>
<userNameAuthentication userNamePasswordValidationMode="Custom" customUserNamePasswordValidatorType="PHGAPI.PHGUserNamePassValidator, PHGAPI"/>
<serviceCertificate
findValue="*.domainname.com"
x509FindType="FindBySubjectName"
storeLocation="LocalMachine"
storeName="My" />
</serviceCredentials>
<serviceThrottling maxConcurrentCalls="200" maxConcurrentSessions="400" maxConcurrentInstances="600" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service behaviorConfiguration="BehaviorRBS" name="PHGAPI.iAPI">
<endpoint address="" binding="customBinding" bindingConfiguration="CommonBinding" contract="PHGAPI.IiAPI" />
</service>
</services>
这是有问题的方法接口:
[OperationContract]
string SetSuspensions(List<Suspension> suspensions);
看起来它被编辑了出来,但是我读到了,你说服务器完成了它的执行?这个错误很可能从服务器抛出,而不是超时。要清楚的是,它的客户端对服务器错误的响应。 – paqogomez
也许会导致序列化问题? – lavrik
@paqogomez我写了一个日志文件在服务器上,并且在'return'成功之前立即写入日志';'线。该日志条目在大约3分钟后发生,大约在客户端收到异常后大约一分钟。正因为如此,我相信服务器运行良好。 – Marcus