【发布时间】:2014-04-25 19:28:01
【问题描述】:
当调用返回字符串“success”的方法时,WCF 客户端会在 120 秒后返回上述异常。服务器的日志显示它完全执行并在大约 3 分钟内完成。启用跟踪后,我看不到任何错误。 任何帮助将不胜感激,因为类似问题的其他建议很遗憾没有帮助。谢谢!
编辑 - 已解决:原来客户端使用的是 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)
内部异常:
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 我已经在服务器上写入了一个日志文件,它在'返回“成功”之前立即写入日志;'线。此日志条目发生在大约 3 分钟后,也就是客户端收到异常后大约一分钟。因此,我相信服务器运行良好。
-
@IgorK,我首先建议查看support.microsoft.com/kb/2538826 并在那里实施建议的调整。顺便说一句,.NET 4.5 的 WCF 运行时已经得到了很大的改进。除此之外,您是否检查过该客户的计算机是否运行任何防病毒/网络过滤器或具有限制性防火墙/代理配置?