2016-04-28 61 views
0

我正在開發與地秤連接的WCF服務。 我們希望在重量發生變化時向所有連接的客戶端發送消息。 一個地磅只能連接一個客戶端,所以我開發了WCF,它通過wsDualHttpBinding和回調與客戶端進行通信。WCF wsDualHttpBinding停止發送回調

此解決方案的工作原理,但長時間(1-2天)WCF服務停止發送回調。 我知道我的服務工作,因爲我有記錄器 - 但我的客戶沒有收到回調。我的服務也不會拋出異常。

這是我的服務pseduo代碼

[ServiceBehavior(ConcurrencyMode = ConcurrencyMode.Reentrant, InstanceContextMode = InstanceContextMode.PerSession)] 
public sealed class WeightbridgeService : IWeightbridgeService, IDisposable 


public WeightbridgeService() 
{ 
     this.callback = OperationContext.Current.GetCallbackChannel<IWeightbridgeServiceCallback>(); 
     weighbridge.WeightChanged += WeightChangedEventHandler; 
     timer.Elapsed += TimerOnElapsed; 
     timer.Start(); 
} 

private void TimerOnElapsed(object sender, ElapsedEventArgs elapsedEventArgs) 
{ 
      timer.Stop(); 
      this.callback.SendWeightData(this.weightData); 
      timer.Start(); 
} 

和配置

<bindings> 
     <wsDualHttpBinding> 
     <binding name="longTimeoutBinding" receiveTimeout="00:45:00" sendTimeout="00:45:00" openTimeout="00:45:00" closeTimeout="00:45:00" > 
      <reliableSession inactivityTimeout="00:45:00" /> 
      <security mode="None"/> 
     </binding> 
     </wsDualHttpBinding> 
    </bindings> 

你能幫我什麼,我做錯了? 我找不到解決方案。

回答

0

您可以將receiveTimeout屬性添加到您的SERVICE配置文件中的綁定中。雖然它的名稱是receiveTimeout,但它是服務器用於關閉「非活動」客戶端連接的值(時間量)。

實施例:

<binding name="wsDualHttpBinding" 
      closeTimeout="00:01:00" 
      openTimeout="00:01:00" 
      receiveTimeout="02:00:00"> <-- this is the amount of time to wait before droppin client connection