簡體   English   中英

WCF服務超時

[英]WCF service timing out

我有一個暴露wcf服務的插件。 如果我使用WCFStorm測試這項服務,一切正常。 我馬上收到回復。 當我嘗試從加載插件的應用程序中使用該服務時,我得到了一個時間。

ProgrammingMaster_ServiceClient aClient = new ProgrammingMaster_ServiceClient();
aClient.Endpoint.Address = new EndpointAddress("http://localhost:8081/ProgrammingMaster/PM_Service");
aClient.BeginProgrammingSession(0x01);
aClient.Close();

我正在使用的代碼來使用該服務。 ProgrammingMaster_SErviceClient由svcutil.exe生成。

如果我刪除該行,我會遇到同樣的問題

aClient.Endpoint.Address = new EndpointAddress("http://localhost:8081/ProgrammingMaster/PM_Service");

我不確定我應該在哪里開始調試這個。

被調用的服務在不同的網絡上發送消息。 當我通過wcfstorm調用它時,我可以看到服務發送的消息。 所以我知道服務正常。

當我從我的應用程序調用導致超時的服務時,我做錯了什么。

編輯:超時后(我正在捕獲並記錄異常),服務在其他網絡上發送它的消息,就像它應該的那樣。

編輯2:希望這是一個更好的解釋。

所以我有一個暴露Web服務的插件,並使用不同的Web服務。 因此,插件基本上連接到特殊網絡上的對象,然后通過使用Web服務傳遞該對象屬性值。

我有一個應用程序,它公開了插件用來提供遠程對象值更新的Web服務,並使用插件公開的Web服務將命令傳遞給遠程對象。

插件向應用程序發送更新時沒有超時問題。 當應用程序使用Web服務通過插件向遠程對象發送命令時,我收到超時錯誤。 超時到期后,執行命令。 因此,Web服務被成功調用。 我想我只是沒有得到回復?

編輯3:這是我的app配置文件。 我將發送超時降低到00:00:01,以便等待時間不長,但我真的想修復它,所以它不必每次都超時。

<?xml version="1.0"?>
<configuration>
  <system.serviceModel>
    <bindings>
      <wsHttpBinding>
        <binding name="WSHttpBinding_IProgrammingMaster_Service" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:00:01" bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="524288" maxReceivedMessageSize="65536" 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:10:00" enabled="false"/>
          <security mode="Message">
            <transport clientCredentialType="Windows" proxyCredentialType="None" realm="">
              <extendedProtectionPolicy policyEnforcement="Never"/>
            </transport>
            <message clientCredentialType="Windows" negotiateServiceCredential="true" algorithmSuite="Default" establishSecurityContext="true"/>
          </security>
        </binding>
      </wsHttpBinding>
    </bindings>
    <client>
      <endpoint address="http://localhost:8081/ProgrammingMaster/PM_Service" binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IProgrammingMaster_Service" contract="IProgrammingMaster_Service" name="WSHttpBinding_IProgrammingMaster_Service">
        <identity>
          <userPrincipalName value="mzjkk7@nam.corp.gm.com"/>
        </identity>
      </endpoint>
    </client>
  </system.serviceModel>
<startup useLegacyV2RuntimeActivationPolicy="true">
  <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
</startup>
</configuration>

哦...

是的,只有在客戶端和服務器都屬於同一個應用程序時才會發生超時。

重要的問題是在同一個線程上運行的客戶端和服務?

如果是這樣,那可能是你的問題。 嘗試在自己的線程中啟動服務,看看是否能解決問題。

打開內置的WCF調試/日志記錄功能:

http://msdn.microsoft.com/en-us/library/ms733025.aspx

這有助於我解決WCF的各種古怪問題。 只需記住在完成后將其關閉 - 它會將大量數據寫入磁盤!

您是否在關閉防火牆的情況下嘗試了它,看看是否可能導致它?

暫無
暫無

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

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