We have a WCF service (NetTcpBinding) that sits behind a load balancer. I’ve read that in order to avoid “stickyniss” I have lower the LeaseTime the channels get in the channel pool.
I’ve only found samples how to set this value using the config file, but I would like to set it programmaticaly, any pointers?
You can access the
LeaseTimeoutproperty via theTcpTransportBindingElement, through theConnectionPoolSettingsproperty:If you have a
NetTcpBindingobject, you’ll need to first convert it into aCustomBinding, then access the binding element. The example below shows one way of doing this.