简体   繁体   English

WCF wsDualHttpBinding停止发送回调

[英]WCF wsDualHttpBinding stop sending callbacks

I am developing WCF service which is connected with weighbridge. 我正在开发与地磅连接的WCF服务。 We would like to send messages to all connected clients when weight changed. 重量发生变化时,我们想向所有连接的客户端发送消息。 With one weighbridge can be connected only one client so I have developed WCF which communicate with clients by wsDualHttpBinding and callbacks. 一个称重桥只能连接一个客户端,因此我开发了WCF,它通过wsDualHttpBinding和回调与客户端进行通信。

This solution works, but after long time(1-2 days) WCF service stop sending callbacks. 此解决方案有效,但是经过很长时间(1-2天)后,WCF服务停止发送回调。 I known my Service works because I have logger - but my clients don't receive callbacks. 我知道我的服务有效是因为我有记录器-但我的客户未收到回调。 My service also don't throw exceptions. 我的服务也不会抛出异常。

It is my service pseduo code 这是我的服务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();
 }

and config 和配置

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

Could you help me what i have done wrong ? 你能帮我做错什么吗? I can't find solution for it. 我找不到解决方案。

You can add the receiveTimeout attribute to your binding in your SERVICE config file. 您可以在SERVICE配置文件中将receiveTimeout属性添加到绑定中。 Although its name is receiveTimeout, it is the value (amount of time) used by the server to close connections for "inactive" clients. 尽管其名称为receiveTimeout,但它是服务器用来关闭“非活动”客户端连接的值(时间)。

Example: 例:

<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