【问题标题】:WCF wsDualHttpBinding stop sending callbacksWCF wsDualHttpBinding 停止发送回调
【发布时间】:2016-04-28 08:35:08
【问题描述】:

我正在开发与地磅连接的 WCF 服务。 当权重发生变化时,我们希望向所有连接的客户端发送消息。 一个地磅只能连接一个客户端,所以我开发了 WCF,它通过 wsDualHttpBinding 和回调与客户端通信。

此解决方案有效,但经过很长时间(1-2 天)WCF 服务停止发送回调。 我知道我的服务有效,因为我有记录器 - 但我的客户没有收到回调。我的服务也不会抛出异常。

这是我的服务伪代码

[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>

你能帮我做错什么吗? 我找不到解决办法。

【问题讨论】:

    标签: c# wcf wsdualhttpbinding


    【解决方案1】:

    您可以在 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
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-05-30
      • 1970-01-01
      • 1970-01-01
      • 2011-01-04
      • 1970-01-01
      相关资源
      最近更新 更多