I've written a system that uses a Duplex NetTcp Channel with a callback to function as a publish/subscribe server.
Do I have to worry about the callback timing out if not connection is sent after a while or will the callback pipe be maintained indefinitely?
The callback won't be maintained indefinitely, It will look for the timeout values you've set in your config. If you enable reliable sessions then you can set the inactivity timeouts of your clients. You can configure timeouts like this:
When these values are reached and there is still no response, your communication channel becomes faulted and you need to re-create a client proxy to consume the service. The default value for
receiveTimeout
is 10 minutes so you can increase that, but also make sure to increase yourinactivityTimeout
as well, yourinactivityTimeout
should be greater than yourreceiveTimeout
.EDIT:
You could keep changing your
receiveTimeout
programmatically based on values your client sends back to the server, the key is keeping the new timeout values same on the service and client. You would go about doing this on the client (an example I'm taking from a chat service I'm making with WCF and consuming with Silverlight clients):In the client configuration:
So you can define multiple endpoints or bindings in the config on your client or your server, then based on whatever event in your application you can instantiate _clientProxyX to consume _serviceInstanceX which will have different binding/endpoint values but the same contract as your previous service instance. In the example above the first binding has a timeout of 1 minute, the second binding 2 minutes. An important point to consider is that if you wish to recreate new client proxies like this, then you need to tear down your old client proxy and crate a new one, which effectively disconnects your clients from the service, at least momentarily.
Also you can modify those values (
openTimeout
,closeTimeout
etc.) programmatically on both the server when instantiating a new service host. You can create a new host, based on one of the binding configurations you've defined in your config, or create a new config programmatically, something like this:This looks quite messy I know, but the point is WCF gives you a lot of flexibility in being able to modify you binding configs programmatically. Be sure to check out this great answer on modifying your WCF config files. And you can also easily create a whole service configuration programmtically.