套接字异常 - WCF [英] Socket Exception - WCF

查看:73
本文介绍了套接字异常 - WCF的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我在我的WCF服务中遇到异常后得到了。



套接字连接已中止。这可能是由于处理消息的错误或远程主机超出接收超时或基础网络资源问题引起的。本地套接字超时为'00:00:59.9355444'。




服务器应用程序配置



Hi ,
I am gettgin following exception in my WCF service.

The socket connection was aborted. This could be caused by an error processing your message or a receive timeout being exceeded by the remote host, or an underlying network resource issue. Local socket timeout was '00:00:59.9355444'.


Server App config

<system.serviceModel>
   <bindings>
     <netTcpBinding>
       <binding name="tcpBinding" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647">
         <security mode="None">
           <transport clientCredentialType="None" protectionLevel="None" />
           <message clientCredentialType="None" />
         </security>
       </binding>
     </netTcpBinding>
   </bindings>
   <services>
     <service behaviorConfiguration="CatWcfServiceLibrary.Service1Behavior"
       name="CatWcfServiceLibrary.CATService">
       <endpoint address="" binding="netTcpBinding" bindingConfiguration="tcpBinding"
         name="epNetTcp" contract="CatWcfServiceLibrary.ICATService" behaviorConfiguration="CatWcfServiceLibrary.Service1Behavior" />
       <endpoint address="" binding="basicHttpBinding" name="epBasicHttp"
         contract="CatWcfServiceLibrary.ICATService" />
       <endpoint address="mex" binding="mexHttpBinding" name="epMex"
         contract="IMetadataExchange" />
       <host>
         <baseAddresses>
           <add baseAddress="http://localhost:8082/CatWcfService" />
           <add baseAddress="net.tcp://localhost:8083/CatWcfService" />
         </baseAddresses>
       </host>
     </service>
   </services>
   <behaviors>
     <serviceBehaviors>
       <behavior name="CatWcfServiceLibrary.Service1Behavior">
         <dataContractSerializer maxItemsInObjectGraph="2147483647"/>
         <!-- To avoid disclosing metadata information,
         set the value below to false and remove the metadata endpoint above before deployment -->
         <serviceMetadata httpGetEnabled="True"/>
         <!-- To receive exception details in faults for debugging purposes,
         set the value below to true.  Set to false before deployment
         to avoid disclosing exception information -->
         <serviceDebug includeExceptionDetailInFaults="true" />
       </behavior>
     </serviceBehaviors>
   </behaviors>
 </system.serviceModel>







客户端应用.Config








Client App.Config


<system.serviceModel>
  <bindings>
    <basicHttpBinding>
      <binding name="epBasicHttp" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true">
        <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384"/>
        <security mode="None">
          <transport clientCredentialType="None" proxyCredentialType="None" realm=""/>
          <message clientCredentialType="UserName" algorithmSuite="Default"/>
        </security>
      </binding>
    </basicHttpBinding>
    <netTcpBinding>
      <binding name="epNetTcp" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" transactionFlow="false" transferMode="Buffered" transactionProtocol="OleTransactions" hostNameComparisonMode="StrongWildcard" listenBacklog="10" maxBufferPoolSize="524288" maxBufferSize="65536" maxConnections="10" maxReceivedMessageSize="65536">
        <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384"/>
        <reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false"/>
        <security mode="None">
          <transport clientCredentialType="Windows" protectionLevel="EncryptAndSign"/>
          <message clientCredentialType="Windows"/>
        </security>
      </binding>
    </netTcpBinding>
  </bindings>
  <behaviors>
    <endpointBehaviors>
      <behavior name="endpointBehavior">
        <dataContractSerializer maxItemsInObjectGraph="2147483647"/>
      </behavior>
    </endpointBehaviors>
  </behaviors>
  <client>
    <endpoint address="net.tcp://catvmappdev01:8083/CatWcfService" binding="netTcpBinding" bindingConfiguration="epNetTcp" behaviorConfiguration="endpointBehavior" contract="ICATService" name="epNetTcp"/>
    <endpoint address="http://catvmappdev01:8082/CatWcfService" binding="basicHttpBinding" bindingConfiguration="epBasicHttp" contract="ICATService" name="epBasicHttp"/>
  </client>
</system.serviceModel>





我的方法中有大约5000条以上的记录。



请帮助



快乐编码

推荐答案

通常我会说这个错误你是通用的,通常会隐藏另一个错误,错误没有显示。



但在你的情况下,你的超时是如此接近一分钟,我认为你达到了这个限制:



sendTimeout =00:01:00



尝试延长这段时间,看看是否需要更长的时间。



It很简单,可能需要花费更长的时间来生成服务器响应。



如果不是,则下一步是跟踪实际呼叫。您需要配置跟踪,然后查看跟踪输出以找到真正的异常。



服务跟踪查看器工具(SvcTraceViewer.exe) [ ^ ]







添加链接文字以反映文章标题。

[/编辑]
Normally I would say this that error you have is generic and generally hides another fault, not shown by the error.

But in your case, your timeout is so close to a minute, I think you're hitting this limit:

sendTimeout="00:01:00"

Try extending this time and see if it takes longer.

It could, quite simply, be taking longer the 1 minute to generate the server the response.

If not the next step is to trace the actual call. You need to configure a trace and then look into the trace output to find the real exception.

Service Trace Viewer Tool (SvcTraceViewer.exe)[^]



Link text added to reflect the article title.
[/Edit]


嗨Stephen,



最后我今天早上得到了突破。

这是最终的伎俩。



1.在服务和客户端配置中添加了这些行为。



Hi Stephen,

Finally I got the break through, today morning.
This was the eventual trick.

1. Added these behaviors at both service and client config.

<behaviors>
<endpointBehaviors>
  <behavior name="endpointBehavior">
    <dataContractSerializer maxItemsInObjectGraph="2147483647"/>
  </behavior>
</endpointBehaviors>
</behaviors>





2.在客户端和服务器配置中将这些值更新为最大大小。





2. Update these values to maximum size in both Client and Server config.

<binding name="tcpBinding" receiveTimeout="00:15:00" sendTimeout="00:15:00"  maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647">
          <security mode="None">
            <transport clientCredentialType="None" protectionLevel="None" />
            <message clientCredentialType="None" />
          </security>
        </binding>





a。 maxReceivedMessageSize

b。 maxBufferSize

c。 maxBufferPoolSize



再次感谢您的帮助。



a. maxReceivedMessageSize
b. maxBufferSize
c. maxBufferPoolSize

Thanks once again for the help.


这篇关于套接字异常 - WCF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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