views:

3478

answers:

1

I have a Windows service that logs speed readings from a radar gun to a database. In addition, I made the service a WCF server. I have a Forms and a CF client that subscribe to the service and get called back whenever there is a reading that satisfies certain criteria.

This works in principle, but after some time the channel times out. It seems that there are some fundamental issues with long-running connections (see http://blogs.msdn.com/drnick/archive/2007/11/05/custom-transport-retry-logic.aspx) and a duplex HTTP callback may not be the right solution. Are there any other ways I can realize a publish/subscribe pattern with WCF?

Edit: Even with a 2 hour timeout the channel is eventually compromised. I get this error:

The operation 'SignalSpeedData' could not be completed because the sessionful channel timed out waiting to receive a message. To increase the timeout, either set the receiveTimeout property on the binding in your configuration file, or set the ReceiveTimeout property on the Binding directly.

This happened 15 minutes after the last successful call. I am wondering if instead of keeping the session open, it is possible to re-establish a fresh session for every call.

+1  A: 

Reliable messaging will take care of your needs. The channel reestablishes itself if there is a problem. WSDualHTTPBinding provides this for the http binding, and there is also a tcp binding that allows this. If you are on the same computer, named pipe binding will provide this by default.

Steve
If you mean reliable session - I am already using that and I set the inactivity timeout to 2 hours.
cdonner
So, RS is "supposed" to send infrastructure messages after your inactivity timeout. Sadly it doesn't in the latest version of the framework. If you send a "heartbeat" message every 20 minutes or so, it should take care of the problem. There is also another setting that I'll need to look up tomorrow.
Steve