tags:

views:

251

answers:

2

I have a piece of code like so

            NetTcpBinding binding = new NetTcpBinding(SecurityMode.Transport);
            binding.Security.Message.ClientCredentialType = MessageCredentialType.Windows;
            binding.CloseTimeout = new TimeSpan(0, 0, 1);
            binding.OpenTimeout = new TimeSpan(0, 0, 1);
            binding.SendTimeout = new TimeSpan(0, 0, 1);
            binding.ReceiveTimeout = new TimeSpan(0, 0, 1);

            EndpointAddress endPoint = new EndpointAddress(new Uri(clientPath));

            DuplexChannelFactory<Iservice> channel = new DuplexChannelFactory<Iservice>(new ClientCallBack(clientName), binding, endPoint);
            channel.Ping()

When the endpoint doesn't exist it still waits 20seconds before throwing an EndpointNotFoundException.

The weird thing is that when i changed the SendTimeout the exception message changed from The connection attempt lasted for a time span of 00:00:20 to ....01 but still took 20seconds to throw the exception!

How can i change this timeout?

A: 

I think this has nothing to do with WCF, because whenever you try to connect to any non existing end point, the OS's TCP/IP layer will certainly go through some steps to first find out DNS if its name based host, and then try to connect to IP end point, and in this the TCP/IP layer will have default timeout of 20 seconds, even if you type any non existing url on IE's address bar, if its connected to internet, it will wait for few seconds before giving you page can not be displayed error. And I think thats the timeout at TCP/IP stack which cant be controlled from WCF.

Akash Kava
Surely the Open timeout includes any OS and network durations? I can't think of any other delays that the Open timeout might be useful for controlling.
Kirk Broadhurst
A: 

See

http://social.msdn.microsoft.com/Forums/en-US/wcf/thread/84551e45-19a2-4d0d-bcc0-516a4041943d

for a summary explanation of WCF timeout knobs. You might want to call channel.Open() explicitly before calling Ping(), so as to un-confound the 'open the session' part from the 'send the first message' part. That said, the other answer (about what happens at the TCP layet) might be right, I forget.

Brian