WCF 服务超时或关闭? [英] WCF service timing out or shutting down?

查看:50
本文介绍了WCF 服务超时或关闭?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近注意到在我们的生产环境中记录了异常,即 WCF 服务在从我的前端服务器到 ib 逻辑服务器的调用之间超时.两者都使用WCF进行通信.前端服务器正在记录以下异常:

I recently noticed in our production environment that exceptions are being logged that WCF services are timing out between calls from my frontend server to ib logic server. Both using WCF to communicate. The frontend server is logging the following exception:

这会间歇性地发生.这是什么原因?和网络有关吗?

This happens intermittently. What's the cause for this? Is it network related?

Timestamp: 23/12/2013 07:59:00.507895
Message: HandlingInstanceID: 58495715-f5d8-49a9-9c90-763a1718228b
An exception of type 'System.ServiceModel.CommunicationException' occurred and was caught.
------------------------------------------------------------------------------------------
12/23/2013 07:59:00
Type : System.ServiceModel.CommunicationException, System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
Message : An error occurred while receiving the HTTP response to https://myservername:2083/IBServer/PayeesService.svc. This could be due to the service endpoint binding not using the HTTP protocol. This could also be due to an HTTP request context being aborted by the server (possibly due to the service shutting down). See server logs for more details.
Source : Facade
Help link : 
Data : System.Collections.ListDictionaryInternal
TargetSite : System.Collections.Generic.List`1[Facade.BusinessObjects.Payee] GetPayeeList()
Stack Trace : 
Server stack trace: 
   at System.ServiceModel.Channels.HttpChannelUtilities.ProcessGetResponseWebException(WebException webException, HttpWebRequest request, HttpAbortReason abortReason)
   at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
   at System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout)
   at System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message message, TimeSpan timeout)
   at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
   at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
   at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)

Exception rethrown at [0]: 
   at IB.Facade.PayeeFacade.GetPayeeList() in Facade.Payees.cs:line 236
   at LoginBase.RetrievePayees()
   at LoginBase.LoadPayees()
   at Login.LoadDefaultCache()

前端 WCF 绑定到事务服务器上的 WCF 服务:

FRONTEND WCF BINDING to WCF Service on Transaction Server:

 <binding name="WSHttpBinding_ManagePayeeService" closeTimeout="00:02:00" openTimeout="00:02:00" receiveTimeout="00:10:00" sendTimeout="00:02:00" bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false">

            <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />

            <reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false" />

            <security mode="Transport">

                <transport clientCredentialType="None" proxyCredentialType="None" realm="" />

                <message clientCredentialType="UserName" algorithmSuite="Default" />

            </security>

        </binding>

事务服务器上的 WCF 绑定:

WCF BINding on Transaction Server:

 <binding name="WSHttpBinding_ManagePayeeService" closeTimeout="00:02:00" openTimeout="00:02:00" receiveTimeout="00:10:00" sendTimeout="00:02:00" bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false">
      <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
      <reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false" />
      <security mode="Transport">
        <transport clientCredentialType="None" proxyCredentialType="None" realm="" />
        <message clientCredentialType="Windows" negotiateServiceCredential="true" establishSecurityContext="true" />
      </security>
    </binding>

推荐答案

您是否尝试查看 svclogs 以获取有关问题的更多信息?

Have you tried looking into the svclogs for getting more information as to what's going wrong?

可以在您的 Web.config 中的 system.diagnostics 元素下配置此日志记录.以下是我偶尔使用的一个测试文件.

This logging can be configured in your Web.config under the system.diagnostics element. The below is taken from one of my test files that I occasionally use.

注意:不要在生产站点上一直保持这种日志记录,因为日志会迅速增长到有问题的大小.因此,每当我将下面的部分投入使用时,我都会尽快将其注释掉.

Note: Do not leave this logging on all the time on a production site, as the logs will quickly grow to a problematic size. For this reason, whenever I put the section below into play I comment it out as soon as possible.

启用这种日志记录时,最好同时捕获客户端和服务器日志.通常,服务器日志会包含未传递到客户端的信息,反之亦然.

When enabling this kind of logging, it works best if you capture both the client and the server logs. Often the server log will have information that isn't passed onto the client, and vice versa.

<system.diagnostics>
  <!--
    Trace Levels:
      Off, Critical, Error, Warning, Information, Verbose, ActivityTracing, All
  -->
  <!--<trace autoflush="true" />-->
  <sources>
    <source name="System.ServiceModel" switchValue="All" propagateActivity="true">
      <listeners>
        <add name="System.ServiceModel" type="System.Diagnostics.XmlWriterTraceListener" initializeData ="C:\Logs\MyWebsiteLogs\SVC\System.ServiceModel.svclog" />
      </listeners>
    </source>
    <source name="System.ServiceModel.MessageLogging" switchValue="All">
      <listeners>
        <add name="System.ServiceModel.MessageLogging" type="System.Diagnostics.XmlWriterTraceListener" initializeData ="C:\Logs\MyWebsiteLogs\SVC\WCF\System.ServiceModel.MessageLogging.svclog" />
      </listeners>
    </source>
    <source name="System.ServiceModel.IdentityModel" switchValue="All">
      <listeners>
        <add name="System.ServiceModel.IdentityModel" type="System.Diagnostics.XmlWriterTraceListener" initializeData ="C:\Logs\MyWebsiteLogs\SVC\WCF\System.ServiceModel.IdentityModel.svclog" />
      </listeners>
    </source>
    <source name="System.ServiceModel.Activation" switchValue="All">
      <listeners>
        <add name="System.ServiceModel.Activation" type="System.Diagnostics.XmlWriterTraceListener" initializeData ="C:\Logs\MyWebsiteLogs\SVC\WCF\System.ServiceModel.Activation.svclog" />
      </listeners>
    </source>
    <source name="System.ServiceModel.Serialization" switchValue="All">
      <listeners>
        <add name="System.ServiceModel.Serialization" type="System.Diagnostics.XmlWriterTraceListener" initializeData ="C:\Logs\MyWebsiteLogs\SVC\WCF\System.ServiceModel.Serialization.svclog" />
      </listeners>
    </source>
    <source name="System.IO.Log" switchValue="All">
      <listeners>
        <add name="System.IO.Log" type="System.Diagnostics.XmlWriterTraceListener" initializeData ="C:\Logs\MyWebsiteLogs\SVC\WCF\System.IO.Log.svclog" />
      </listeners>
    </source>
    <source name="Cardspace" switchValue="All">
      <listeners>
        <add name="Cardspace" type="System.Diagnostics.XmlWriterTraceListener" initializeData ="C:\Logs\MyWebsiteLogs\SVC\WCF\Cardspace.svclog" />
      </listeners>
    </source>
  </sources>
</system.diagnostics>

您可以使用 服务查看日志跟踪查看器工具.此工具可能已安装,也可能尚未安装在您当前版本的 Visual Studio/.NET Framework 中.

You can view the logs using the Service Trace Viewer Tool. This tool may or may not already be installed alongside your current version of Visual Studio / .NET Framework.

对于上下文,我发现每当我在 WCF 中遇到这样的通信异常时,它总是结果是服务器上的某种序列化错误.然而,这只是我的经验,不确定其他什么情况会产生这样的错误.

For context, I find that whenever I get a communication exception like this in WCF it always turns out to be a serialization error of some kind on the server. That's just in my experience however, not sure of what other scenarios could generate an error like this.

这篇关于WCF 服务超时或关闭?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆