无法解决WCF超时错误

时间:2014-07-15 21:11:12

标签: c# .net wcf

我一直从我的QA服务器收到以下错误:

  

消息:{strMessage = Class:ShopProcessServiceClient方法:主错误:接收到http://xxx.xxx.x.xxx/RyderShopProcessService/ShopProcessService.svc的HTTP响应时发生错误。这可能是由于服务端点绑定不使用HTTP协议。这也可能是由于服务器中止HTTP请求上下文(可能是由于服务关闭)。请参阅服务器日志以获取更多详InnerException:System.Net.WebException:基础连接已关闭:接收上发生意外错误。 ---> System.IO.IOException:无法从传输连接读取数据:远程主机强制关闭现有连接。 ---> System.Net.Sockets.SocketException:System.Net.Sockets上的System.Net.Sockets.Socket.Receive(Byte []缓冲区,Int32偏移量,Int32大小,SocketFlags socketFlags)上的远程主机强制关闭现有连接。 NetworkStream.Read(Byte []缓冲区,Int32偏移量,Int32大小)---内部异常堆栈跟踪结束---在System.Net.Sockets.NetworkStream.Read(Byte []缓冲区,Int32偏移量,Int32大小)处于System.Net.Connection.SyncRead中的System.Net.PooledStream.Read(Byte []缓冲区,Int32偏移量,Int32大小)(HttpWebRequest请求,布尔userRetrievedStream,布尔探测器读取)---内部异常堆栈跟踪结束--- at System.ServiceModel.Channels.HttpChannelFactory 1.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout) Source: mscorlib StackTrace: Server stack trace: at System.ServiceModel.Channels.HttpChannelUtilities.ProcessGetResponseWebException(WebException webException, HttpWebRequest request, HttpAbortReason abortReason) at System.ServiceModel.Channels.HttpChannelFactory中的System.Net.HttpWebRequest.GetResponse()在System.ServiceModel.Channels.RequestChannel.Request(消息消息,TimeSpan超时)的1.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan超时)在System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Mess System.ServiceModel.Channels.ServiceChannelProxy.InvokeService上的System.ServiceModel.Channels.ServiceChannel.Call(String action,Boolean oneway,ProxyOperationRuntime operation,Object [] ins,Object [] outs,TimeSpan timeout)中的age消息,TimeSpan超时) System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)中的IMethodCallMessage methodCall,ProxyOperationRuntime操作)在[0]处重新抛出异常:在System.Runtime的System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg,IMessage retMsg)处.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData&安培; msgData,Int32类型)在Ryder.ShopProcessService.Outbound.ShopProcessService.IShopProcessService.GetCusts()中的Ryder.ShopProcessService.Outbound.ShopProcessService.ShopProcessServiceClient.GetCusts()在c:\ Development \ SMO_VS_2013 \ HHOutboundClient \ SOASolutionA \ Ryder.ShopProcessService.Outbound \ Service References \ ShopProcessService \ Reference.cs:第7698行,位于c:\ Development \ SMO_VS_2013 \ HHOutboundClient \ SOASolutionA \ Ryder.ShopProcessService.Outbound \ ShopProcessServiceClient.cs中的Ryder.ShopProcessService.Outbound.ShopProcessServiceClient.Main(String [] args):第399行,strProject = Ryder.ShopProcessService.Outbound,strRemedyTktResponse = INC000000091594}扩展属性:

在查找上述文本中的相关错误时,他们都指向增加发送/接收超时和/或最大化发送的数据值(如maxItemsInObjectGraph =“2147483647”)我已经完成了两项工作但仍无法解决此错误。

当我在 Visual Studio中使用相同设置运行相同应用程序时,不会发生错误< / strong>即可。 仅在我们的QA服务器上运行时才会出现

在处理大约170,000条记录左右的相同集合时,它总是崩溃。下一个最大的一个是大约50,000条记录。它确实让它过了一次,但随后的尝试都失败了。

我感兴趣的错误中的另一件事如下: System.IO.IOException:无法从传输连接中读取数据

另外值得注意的是,我有一个命令超时(对于sql执行,虽然经过调试,只需几秒钟)的5分钟,当5分钟启动时,发生了错误。当我取消命令超时并将其保留为默认值时,它在默认值时间崩溃。这可能告诉我它在读取数据库中的数据时遇到了麻烦。

如果有人可以告诉我还有什么可以改变来解决这个错误,我会非常感激。

以下是我服务的 web.config文件设置

<system.serviceModel>
    <client>
      <endpoint address="http://999.999.99.999/RyderCommonServices/ContentManagementService.svc"
        binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ContentManagementService"
        contract="ContentManagementService.ContentManagementService"
        name="BasicHttpBinding_ContentManagementService" />
    </client>
    <services>
      <service name="Ryder.ShopProcessService.SOA.ShopProcessService" behaviorConfiguration="ServiceBehavior">
        <endpoint address="" binding="wsHttpBinding" contract="Ryder.ShopProcessService.SOA.IShopProcessService" bindingConfiguration="WsHttpBinding_IShopProcessService">
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
        <host>
          <baseAddresses>
            <!--<add baseAddress="\\miavdeteoabweb\c$\inetpub\Dev\RyderShopProcessService" />-->
          </baseAddresses>
        </host>
      </service>
    </services>
    <bindings>
      <wsHttpBinding>
        <binding name="WsHttpBinding_IShopProcessService" closeTimeout="00:10:00"
          openTimeout="00:10:00" receiveTimeout="00:30:00" sendTimeout="00:30:00"
          maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647">
          <readerQuotas maxStringContentLength="2147483647" maxArrayLength="2147483647"
            maxBytesPerRead="2147483647" />
          <security mode="None" />
        </binding>
      </wsHttpBinding>
    </bindings>
    <diagnostics wmiProviderEnabled="false" performanceCounters="All">
      <messageLogging logMessagesAtTransportLevel="true" logMessagesAtServiceLevel="true" logMalformedMessages="true" logEntireMessage="true" maxSizeOfMessageToLog="2147483647" maxMessagesToLog="500" />
    </diagnostics>
    <behaviors>
      <serviceBehaviors>
        <behavior name="ServiceBehavior">
          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
          <serviceDebug includeExceptionDetailInFaults="true"/>
          <dataContractSerializer maxItemsInObjectGraph="2147483647" />
          </behavior>
      </serviceBehaviors>
    </behaviors>
    <protocolMapping>
      <!--<add scheme="http" binding="basicHttpBinding"/>-->
      <add scheme="https" binding="wsHttpBinding"/>
    </protocolMapping>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
  </system.serviceModel>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true" />
    <security>
      <requestFiltering>
        <requestLimits maxAllowedContentLength="2147483647" />
      </requestFiltering>
    </security>

这是我的客户的相关app.config设置:

<system.serviceModel>
    <bindings>
       <wsHttpBinding>
        <binding name="WsHttpBinding_IShopProcessService" closeTimeout="00:10:00"
          openTimeout="00:10:00" receiveTimeout="00:30:00" sendTimeout="00:30:00"
          maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647">
          <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
            maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
          <security mode="None" />
        </binding>
        <binding name="WSHttpBinding_IShopProcessService">
          <security mode="None" />
        </binding>
      </wsHttpBinding>
    </bindings>
    <diagnostics wmiProviderEnabled="true">
      <messageLogging logMessagesAtTransportLevel="true" logMessagesAtServiceLevel="true" logMalformedMessages="true" logEntireMessage="true" maxSizeOfMessageToLog="2147483647" maxMessagesToLog="100" />
    </diagnostics>
    <client>
      <endpoint address="https://ryderfitest.velsol.com/RyderDataPortal/RyderService.svc"
        behaviorConfiguration="BasicHttpBinding_RyderService" binding="basicHttpBinding"
        bindingConfiguration="BasicHttpBinding_RyderService" contract="HHOutBoundService.IRyderService"
        name="BasicHttpBinding_RyderService" />
      <endpoint address="http://999.999.9.999/RyderShopProcessService/ShopProcessService.svc" behaviorConfiguration="WsHttpBinding_IShopProcessService"
                binding="wsHttpBinding" bindingConfiguration="WsHttpBinding_IShopProcessService"
                contract="ShopProcessService.IShopProcessService" name="WsHttpBinding_IShopProcessService" />
    </client>
    <behaviors>
      <endpointBehaviors>
        <behavior name="WsHttpBinding_IShopProcessService">
          <dataContractSerializer maxItemsInObjectGraph="2147483647"/>
        </behavior>
        <behavior name="webhttp">
          <webHttp/>
        </behavior>
        <behavior name="BasicHttpBinding_RyderService">
          <dataContractSerializer maxItemsInObjectGraph="2147483647"/>
        </behavior>
      </endpointBehaviors>
    </behaviors>
  </system.serviceModel>

1 个答案:

答案 0 :(得分:0)

我通过更新发送/接收/打开/关闭超时来解决错误。见下文。

<binding name="WsHttpBinding_IShopProcessService" closeTimeout="00:30:00"
          openTimeout="00:30:00" receiveTimeout="00:30:00" sendTimeout="00:30:00"
          maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647">
          <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
            maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
          <security mode="None" />
        </binding>