Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Long-running callback contract via WCF duplex channel - alternative design patterns?

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.

like image 875
cdonner Avatar asked Mar 01 '09 18:03

cdonner


People also ask

What are duplex contracts in WCF?

A duplex contract allows clients and servers to communicate with each other independently so that either can initiate calls to the other. The duplex contract is one of three message patterns available to Windows Communication Foundation (WCF) services. The other two message patterns are one-way and request-reply.

Which HTTP binding is used for duplex contracts?

This is the WsDualHttpBinding. This binding is designed for use with Duplex Service contracts, which allows both the Services and clients to send and receive the messages.

Do you need to use session object explicitly in duplex WCF service?

A duplex contract does not require a session, although the system-provided duplex bindings make use of them.


1 Answers

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.

like image 182
Steve Avatar answered Sep 20 '22 11:09

Steve