簡體   English   中英

WCF wsDualHttpBinding停止發送回調

[英]WCF wsDualHttpBinding stop sending callbacks

我正在開發與地磅連接的WCF服務。 重量發生變化時,我們想向所有連接的客戶端發送消息。 一個稱重橋只能連接一個客戶端,因此我開發了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>

你能幫我做錯什么嗎? 我找不到解決方案。

您可以在SERVICE配置文件中將receiveTimeout屬性添加到綁定中。 盡管其名稱為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

暫無
暫無

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

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