首页 新闻 赞助 找找看

WCF 报错,求解救

0
悬赏园豆:50 [已解决问题] 解决于 2014-01-16 16:47

我是写的一个同步AD域的 WCF.

就一个方法 void SyncADUserInfo(),总共8个域需要同步,大概10分钟左右。
现在我的client端在调用服务后,8个域正常同步,但是当同步完后客户端却exception报错.
而当我把同步的域的个数改成两个时,就正常了.

我的超时时间已经改成了30分钟,但是如果真的是超时的问题也应该报超时错误啊,

求帮忙看看
报错信息如下

接收对 http://nb1212009:9999/ADHelper 的 HTTP 响应时发生错误。这可能是由于服务终结点绑定未使用 HTTP 协议造成的。这还可能是由于服务器中止了 HTTP 请求上下文(可能由于服务关闭)所致。有关详细信息,请参见服务器日志。

Server Config:

  <system.web>
    <compilation debug="true" />
  </system.web>
  <system.serviceModel>
    <behaviors>
      <serviceBehaviors>
        <behavior name="ADHelperBehavior">
          <serviceThrottling maxConcurrentCalls="20" maxConcurrentSessions="20" maxConcurrentInstances="30" />
          <serviceMetadata httpGetEnabled="true"  />
          <serviceDebug includeExceptionDetailInFaults="true" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <services>
      <service name="Diodes.BPMService.ADHelper"  behaviorConfiguration="ADHelperBehavior">
        <endpoint address="" contract="Diodes.BPMService.BPMInterface.IADHelper" binding="wsHttpBinding"  />
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
        <host>
          <baseAddresses>
            <add baseAddress="http://nb1212009:9999/ADHelper" />
          </baseAddresses>
        </host>
      </service>
    </services>
    <bindings>
      <wsHttpBinding>
        <binding name="WSHttpBinding_IADHelper" closeTimeout="00:01:00"
          openTimeout="00:01:00" receiveTimeout="00:20:00" sendTimeout="00:20:00"
          bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
          maxBufferPoolSize="524288000" maxReceivedMessageSize="65536000"
          messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
          allowCookies="false">
          <reliableSession ordered="true" inactivityTimeout="00:30:00" enabled="true" />
          <readerQuotas maxStringContentLength="20971520" maxArrayLength="20971520"/>
          <security mode="None" />
        </binding>
      </wsHttpBinding>
    </bindings>
  </system.serviceModel>

Client配置:

 <system.serviceModel>
    <bindings>
      <wsHttpBinding>
        <binding name="WSHttpBinding_IADHelper" closeTimeout="00:01:00"
          openTimeout="00:01:00" receiveTimeout="00:20:00" sendTimeout="00:20:00"
          bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
          maxBufferPoolSize="524288000" maxReceivedMessageSize="65536000"
          messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
          allowCookies="false">
          <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
            maxBytesPerRead="4096" maxNameTableCharCount="16384" />
          <reliableSession ordered="true" inactivityTimeout="00:30:00"
            enabled="false" />
          <security mode="Message">
            <transport clientCredentialType="Windows" proxyCredentialType="None"
              realm="" />
            <message clientCredentialType="Windows" negotiateServiceCredential="true"
              algorithmSuite="Default" />
          </security>
        </binding>
      </wsHttpBinding>
    </bindings>
    <client>
      <endpoint address="http://nb1212009:9999/ADHelper" binding="wsHttpBinding"
        bindingConfiguration="WSHttpBinding_IADHelper" contract="wcfADService.IADHelper"
        name="WSHttpBinding_IADHelper">
        <identity>
          <servicePrincipalName value="host/NB1212009.sh.bcd.com" />
        </identity>
      </endpoint>
    </client>
  </system.serviceModel>
WCF
Color4days的主页 Color4days | 初学一级 | 园豆:157
提问于:2014-01-15 15:59
< >
分享
最佳答案
0

设置 InactiveTimeout ,要比 send 和 recv 大。

收获园豆:50
Launcher | 高人七级 |园豆:45045 | 2014-01-15 16:35

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

enable要改成true吗?

Color4days | 园豆:157 (初学一级) | 2014-01-16 09:06

@Color4days: 要

Launcher | 园豆:45045 (高人七级) | 2014-01-16 09:17

@Launcher: enable改成true 报这个错:从另一方收到未进行安全处理或安全处理不正确的错误。有关错误代码和详细信息,请参见内部 FaultException。

不改成true,inactivityTime改了比receive大还是报原来那个错...

Color4days | 园豆:157 (初学一级) | 2014-01-16 09:27

@Launcher: sorry, 我才意识到是加在server端, 我刚在server加了<reliableSession ordered="true" inactivityTimeout="00:30:00" enabled="true" />  但是执行完后还是报这个错啊。求解释。

我执行的时间大概是11分钟,总是感觉设置的时间没生效,超过10分钟就报错的感觉。

Color4days | 园豆:157 (初学一级) | 2014-01-16 09:57

@Color4days: 你把服务器端的日志记录功能打开,看下服务器端日志中的错误提示。

Launcher | 园豆:45045 (高人七级) | 2014-01-16 10:15

@Launcher: 搞了半天没看到具体的报错...

Color4days | 园豆:157 (初学一级) | 2014-01-16 13:18

@Color4days: 大致是因为 RequestContext aborted,你注意看下时间,从 To: Execute 到 From: Execute 的间隔,大概是 10 分钟。检查下你的客户端和服务器端的 timeout 设置有为 10 分钟的项目,然后修改大点。

Launcher | 园豆:45045 (高人七级) | 2014-01-16 14:09

@Launcher: 我刚把配置文件重新修改了下,主题的配置文件是最新的.

我看报错好像是当执行完回来的时候,却已经关闭的意思...

还是报错啊,能帮我看下代码不?

Color4days | 园豆:157 (初学一级) | 2014-01-16 15:12

@Color4days: 不能帮忙看代码,你最好自己多写代码测试,新建一个wcf 服务项目,只有一个方法,该方法 Sleep(30分钟)然后返回。

Launcher | 园豆:45045 (高人七级) | 2014-01-16 15:21

@Launcher: 那看了我的日志后可以确定就是超时吗?

Color4days | 园豆:157 (初学一级) | 2014-01-16 15:59

@Color4days: 是超时,你的异常里面就没有一点详细的信息么?

Launcher | 园豆:45045 (高人七级) | 2014-01-16 16:12

@Launcher: 谢谢您的解答,我找到原因了. 因为我的 endpoit 没有添加bindingconfigration.导致我的超时设置没有生效.现在好了.谢谢您的耐心解答.

Color4days | 园豆:157 (初学一级) | 2014-01-16 16:46
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册