WCF:遇到单向回调问题

Ben*_*Ben 6 wpf wcf binding timeout

从WCF服务调用WPF客户端的单向回调时,我不断遇到这个令人费解的错误.

消息无法在分配的00:01:00超时内传输.可靠频道的传输窗口中没有可用空间.分配给此操作的时间可能是较长超时的一部分.

它不会发送太多数据,只是一个只有一个短字符串的字符串列表.

我的服务器有以下配置:

<xml version="1.0"?>
<configuration>

  <system.web>
    <compilation debug="true" targetFramework="4.0" />
  </system.web>
  <system.serviceModel>
    <services>
      <service name="RawDealService.GameService">
        <endpoint address ="" binding="wsDualHttpBinding" bindingConfiguration="basicConfig" contract="MyService.IGameService">
          <identity>
            <dns value="localhost"/>
          </identity>
        </endpoint>
      </service>
    </services>
    <bindings>
      <wsDualHttpBinding>
        <binding name="basicConfig" messageEncoding="Text">
          <security mode="None"/>
        </binding>
      </wsDualHttpBinding>
    </bindings>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <!-- 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>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
  </system.serviceModel>
 <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
  </system.webServer>

</configuration>
Run Code Online (Sandbox Code Playgroud)

我的客户端有以下配置:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <system.serviceModel>
        <bindings>
            <wsDualHttpBinding>
                <binding name="WSDualHttpBinding_IGameService" closeTimeout="00:01:00"
                    openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
                    bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
                    maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
                    messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true">
                    <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                        maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                    <reliableSession ordered="true" inactivityTimeout="00:10:00" />
                    <security mode="None">
                        <message clientCredentialType="Windows" negotiateServiceCredential="true" />
                    </security>
                </binding>
            </wsDualHttpBinding>
        </bindings>
        <client>
            <endpoint address="http://localhost:44259/GameService.svc" binding="wsDualHttpBinding"
                bindingConfiguration="WSDualHttpBinding_IGameService" contract="IGameService"
                name="WSDualHttpBinding_IGameService">
                <identity>
                    <dns value="localhost" />
                </identity>
            </endpoint>
        </client>
    </system.serviceModel>

  <startup useLegacyV2RuntimeActivationPolicy="true">
    <supportedRuntime version="v4.0" />
  </startup>
</configuration>
Run Code Online (Sandbox Code Playgroud)

考虑到消息相对较小并且回调只是单向的,这可能会发生这种情况令人困惑.我应该尝试一些不同的绑定吗?

Ben*_*Ben 6

我发现了这个问题,不幸的是,这个特殊的错误信息让我走上了一条完全错误的道路.

我的DataContract设置有一些继承的类,我没有正确标记为KnownTypes.

我的猜测是在某些时候客户端试图反序列化一个相关的对象并失败了.错误一定不是由框架优雅地处理的,也许它一直在尝试一遍又一遍地发送,并且在一分钟后没有得到响应.

也许如果我有一个双向通话,我会得到一个更丰富的堆栈跟踪.