2010-02-09 136 views
3

我有一個用Silverlight 3.0編寫的應用程序。它使用RIA服務在客戶端和服務器之間進行通信。RIA服務WCF超時

我的問題似乎沒有在網上回答得很好。客戶端使用RIA服務與服務器通信,後者在後臺使用WCF。如果通信時間超過60秒,則會通過此消息超時,

'查詢'ApplyUpgrade'的加載操作失敗。 HTTP請求'http://localhost:52403/ClientBin/DatabaseUpgradeTool-Web-UpgradePackageDomainService.svc/binary'已超出分配的超時時間。分配給此操作的時間可能是更長時間的一部分。

我的服務器正在執行數據庫升級,所以它的有效時間超過60秒。可能是雙倍或三倍。

我想這樣的設置在web.config,

<services> 
    <service name="DatabaseUpgradeTool.Web.UpgradePackageDomainService"> 
     <endpoint address="" binding="wsHttpBinding" contract="DatabaseUpgradeTool.Web.UpgradePackageDomainService"></endpoint> 
     <endpoint address="/soap" binding="basicHttpBinding" contract="DatabaseUpgradeTool.Web.UpgradePackageDomainService"></endpoint> 
     <endpoint address="/binary" binding="customBinding" bindingConfiguration="BinaryHttpBinding" contract="DatabaseUpgradeTool.Web.UpgradePackageDomainService"></endpoint> 
    </service> 
    </services> 
<bindings> 
    <customBinding> 
     <binding name="BinaryHttpBinding" 
       receiveTimeout="00:00:10" 
       sendTimeout="00:00:10" 
       openTimeout="00:00:10" 
       closeTimeout="00:00:10"> 
     <binaryMessageEncoding /> 
     <httpTransport keepAliveEnabled="true"/> 
     </binding> 
    </customBinding> 
    </bindings> 

仍然沒有喜悅。任何想法,以什麼是我上面嘗試過什麼是錯的?我期望以上,導致它在10秒內超時,而不是60.

謝謝。

+0

請注意以上更新的問題。我在web.config中嘗試了一些設置,但它們並沒有奏效。它可能引發一些其他的見解 – peter 2010-02-09 21:20:21

+0

看看[相同的問題](http://stackoverflow.com/questions/1912762/configuring-the-timeout-for-a-wcf-ria-services-call-from-a -silverlight -3-客戶端) – Timores 2010-08-09 10:16:34

回答

0

我面臨同樣的問題,我貼這個問題的答案問題在這裏:Silverlight 4 WCF RIA Service Timeout Problem

下面是答案:

我會解釋我的背景,我希望它會爲我工作。我很確定。

首先調用RIA服務,並使用一些領域的背景下,我的例子:

EmployeeDomainContext context = new EmployeeDomainContext(); 
InvokeOperation<bool> invokeOperation = context.GenerateTMEAccessByEmployee(1, 'Bob'); 
invokeOperation.Completed += (s, x) => 
    {....}; 

沒有新東西,直到這裏。與此同時,我每次在1分鐘後都面臨同樣的超時異常。我花了很多時間試圖去面對如何改變超時定義,我嘗試了Web.config中的所有可能的改變,而沒有做任何改變。解決的辦法是:

創建CustomEmployeeDomainContext,即在生成的代碼的相同路徑localizated的局部類和此類中使用的鉤方法OnCreate中改變創建域上下文的行爲。在這堂課你應該寫:

public partial class EmployeeDomainContext : DomainContext 
{ 
    partial void OnCreated() 
    { 
     PropertyInfo channelFactoryProperty = this.DomainClient.GetType().GetProperty("ChannelFactory"); 
     if (channelFactoryProperty == null) 
     { 
      throw new InvalidOperationException(
       "There is no 'ChannelFactory' property on the DomainClient."); 
     } 

     ChannelFactory factory = (ChannelFactory)channelFactoryProperty.GetValue(this.DomainClient, null); 

     factory.Endpoint.Binding.SendTimeout = new TimeSpan(0, 10, 0); 

    } 
} 

我期待您的反饋。