简体   繁体   中英

WCF wsDualHttpBinding stop sending callbacks

I am developing WCF service which is connected with weighbridge. 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.

This solution works, but after long time(1-2 days) WCF service stop sending callbacks. 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

[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. Although its name is receiveTimeout, it is the value (amount of time) used by the server to close connections for "inactive" clients.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM