user702769
user702769

Reputation: 2445

Why is Binding.CloseTimeout value ignored?

Sessionful client has Binding.CloseTimeout set to 20 seconds:

<netTcpBinding>
  <binding name="NetTcpBinding_IService" closeTimeout="00:00:20" ...

a) If service isn't running at the time client calls proxy.Close, then client should wait for 20 seconds ( due to CloseTimeout being set to 20 seconds ) before throwing an exception, but instead exception is thrown almost immediately:

»The socket connection was aborted. This could be caused by an error processing your message or a receive timeout being exceeded by the remote host, or an underlying network resource issue. Local socket timeout was '00:00:20'.«

Why is CloseTimeout value ignored by client?

thank you

Upvotes: 2

Views: 1944

Answers (1)

Matthew Read
Matthew Read

Reputation: 1863

Imagine the client and server are people, and they have a meeting at noon.

The client shows up promptly at noon. If the server isn't there then the client leaves immediately, saying "Screw it!" (throwing an exception).

If the server is there, they commence negotiations (setting up a connection). If the meeting lasts less than CloseTimeout it's because they've come to an agreement (the connection has been set up). If they run out of time for the meeting, they abandon their negotiations (the connection attempt times out).

Lest you think I'm making this up, it's confirmed by the answer to this question over on MSDN:

EncpointNotFoundException [sic] usually occurs if the service cannot be found on the specified address. This exception will be thrown immediately. But if the service is found, yet the sessionful channel cannot be established within 20 seconds, you'll encounter the timeout error.

Upvotes: 2

Related Questions