[英]WCF: Having trouble with one-way callbacks
從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>
我的客戶端有以下配置:
<?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>
考慮到消息相對較小並且回調只是單向的,這可能會發生這種情況令人困惑。 我應該嘗試一些不同的綁定嗎?
我發現了這個問題,不幸的是,這個特殊的錯誤信息讓我走上了一條完全錯誤的道路。
我的DataContract設置有一些繼承的類,我沒有正確標記為KnownType
。
我的猜測是在某些時候客戶端試圖反序列化一個相關的對象並失敗了。 錯誤一定不是由框架優雅地處理的,也許它一直在嘗試一遍又一遍地發送,並且在一分鍾后沒有得到響應。
也許如果我有一個雙向通話,我會得到一個更豐富的堆棧跟蹤。
它聞起來像一個阻塞/線程問題而不是網絡問題。
您是否有任何機會阻止/等待客戶端收到的單向消息? 如果是這樣,並且您正在使用同步上下文,則會使WCF死鎖 - 阻塞等待消息的消息隊列,而在消息隊列被解除阻塞之前無法接收消息。
如果是這種情況,您需要在客戶端上設置UseSynchronizationContext=false
,或者在等待接收消息時避免阻塞。
也就是說,我對WsDualHttpBinding沒有太多經驗。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.