簡體   English   中英

WCF 客戶端錯誤 - 等待回復時請求通道超時

[英]WCF Client Error - The request channel timed out while waiting for a reply

我有一個 Windows 服務,它在我的網絡上的一台機器上托管 WCF 服務。 我有一個客戶端試圖在網絡上的另一台機器上連接到它。 當我連接並嘗試訂閱 WCF 服務時出現以下錯誤:

請求通道在 00:00:09.9989999 之后等待回復時超時。 增加傳遞給 Request 調用的超時值或增加 Binding 上的 SendTimeout 值。 分配給此操作的時間可能是較長超時的一部分。

我已經向客戶端和服務添加了跟蹤以嘗試找出問題,但我無法理解。

這是服務 app.config:

<?xml version="1.0"?>
<configuration>
  <system.serviceModel>
    <services>
      <service name="OSAERest.api" behaviorConfiguration="MyServiceBehavior">
        <endpoint address="http://localhost:8732/api"
                  binding="webHttpBinding"
                  contract="OSAERest.IRestService"
                  behaviorConfiguration="WebHttp"/>
      </service>
      <service name="WCF.WCFService" behaviorConfiguration="WCFBehavior">
        <endpoint address="" binding="wsDualHttpBinding" bindingConfiguration="WCFBinding" contract="WCF.IWCFService">
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>
        <endpoint
          address="mex"
          binding="mexHttpBinding"
          bindingConfiguration=""
          contract="IMetadataExchange"/>
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:8731/Design_Time_Addresses/WCF/WCFService/" />
          </baseAddresses>
        </host>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="MyServiceBehavior">
          <serviceMetadata httpGetEnabled="true"/>
          <serviceDebug includeExceptionDetailInFaults="true" />
        </behavior>
        <behavior name="WCFBehavior">
          <serviceMetadata httpGetEnabled="true"/>
          <serviceDebug includeExceptionDetailInFaults="true" />
          <dataContractSerializer maxItemsInObjectGraph="6553600" />
          <serviceTimeouts transactionTimeout="05:05:00" />
          <serviceThrottling maxConcurrentCalls="500" maxConcurrentSessions="500"
           maxConcurrentInstances="2147483647" />
        </behavior>
      </serviceBehaviors>
      <endpointBehaviors>
        <behavior name="WebHttp">
          <webHttp />
        </behavior>
      </endpointBehaviors>
    </behaviors>
    <bindings>
      <wsDualHttpBinding>
        <binding name="WCFBinding">
          <security mode="None">
          </security>
        </binding>
      </wsDualHttpBinding>

    </bindings>
  </system.serviceModel>
  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
  </startup>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <probing privatePath="lib" />
    </assemblyBinding>
  </runtime>
  <system.diagnostics>
    <sources>
      <source name="System.ServiceModel"
              switchValue="Information, ActivityTracing"
              propagateActivity="true">
        <listeners>
          <add name="traceListener"
              type="System.Diagnostics.XmlWriterTraceListener"
              initializeData= "Logs\ServiceTraces.svclog" />
        </listeners>
      </source>
    </sources>
  </system.diagnostics>
</configuration>

這是客戶端 app.config:

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

    <add key="ServiceIP" value="127.0.0.1"/>


  </appSettings>
  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
  </startup>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <probing privatePath="lib" />
    </assemblyBinding>
  </runtime>
  <system.serviceModel>
    <bindings>
      <wsDualHttpBinding>
        <binding name="WSDualHttpBinding_IWCFService" closeTimeout="00:00:10"
          openTimeout="00:00:10" receiveTimeout="00:00:10" sendTimeout="00:00:10"
          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:8731/Design_Time_Addresses/WCF/WCFService/"
        binding="wsDualHttpBinding" bindingConfiguration="WSDualHttpBinding_IWCFService"
        contract="WCFService.IWCFService" name="WSDualHttpBinding_IWCFService">
        <identity>
          <dns value="localhost" />
        </identity>
      </endpoint>
    </client>
  </system.serviceModel>
  <system.diagnostics>
    <sources>
      <source name="System.ServiceModel"
              switchValue="Information, ActivityTracing"
              propagateActivity="true">
        <listeners>
          <add name="traceListener"
              type="System.Diagnostics.XmlWriterTraceListener"
              initializeData= "Logs\Traces.svclog" />
        </listeners>
      </source>
    </sources>
  </system.diagnostics>
</configuration>

服務上的跟蹤顯示了來自客戶端的連接詳細信息,因此它必須在一定程度上通過。 此外,當我從與服務相同的機器上運行客戶端時,一切正常。 我可能需要做什么才能使遠程連接正常工作?

這很可能是防火牆問題 - wsDualHttpBinding 嘗試打開從服務器返回到客戶端的第二個連接,這可能會被任何防火牆阻止

NetTcpBinding 對於雙工通信要健壯得多,因為我在這里寫過博客

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM