2

I am calling the service from code and if the service is stopped for any reason it gives me EndPointNotFound exception.

 <binding name="NormalMode" transferMode="Buffered" receiveTimeout="24.20:31:23.6470000">
      <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/>
      <security mode="None" />
    </binding>

I haven't set the openTimeOut so it will consider the default 1 minute timeout.

I am calling the service this way,

 private void MyServiceCall(Action serviceCall)
    {
        try
        {
            if (serviceCall != null)
            {
                serviceCall();
            }
        }
        catch (EndpointNotFoundException endpointNotFoundException)
        {
                            throw new EndpointNotFoundException(endpointNotFoundException.Message, endpointNotFoundException);
        }

My question is if service is stopped then will it take 1 minute to throw the EndPointNotFoundException??

EDIT::

In this case i know that service is stopped. I am testing it that way by stopping the service. The question is we have developed the disconnected senario and if service is stoped than it will return the default data but it takes time so i am investigatig is it the openTimeOut which is responsible for it.

Learner
  • 1,490
  • 2
  • 22
  • 35
  • 1
    May I ask why you throw an `EndpointNotFoundException` within a catch block that catches an `EndpointNotFoundException`? – Thorsten Dittmar Apr 04 '12 at 09:01
  • @Thorsten Dittmar: Very good question. I would expect someone to at least log the exception before rethrowing it. – Tudor Apr 04 '12 at 09:05
  • 1
    If you need to rethrow exception, `throw` only will be sufficient. – Nikola Markovinović Apr 04 '12 at 09:11
  • I am logging the exception before throwing it, i've removed that lines. And will it make difference if i only write throw..i mean any stack difference to client side – Learner Apr 04 '12 at 09:15
  • Throw will throw exact exception, exact stack trace as it was at the moment of original throw. If you do not want that, throw exception you got in catch: `catch(Exception ex) { throw ex; }` – Nikola Markovinović Apr 04 '12 at 09:24

2 Answers2

2

There are a large number of reasons why a client connect could fail , e.g. Network issues, Server App Pool is stopped / locked, server ThreadPool exhausted etc.

These won't necessarily throw an EndpointNotFoundException - e.g. if an App Pool is stopped, a 503 error appears as a ServiceTooBusyException on the client. In this case, the error will happen 'immediately' and won't 'wait' for the configured timeout duration of for the service to 'resurrect' itself on the server. (i.e. openTimeout specifies the maximum time permitted)

You are probably better off catching one of the base Exceptions and working from there, e.g. System.ServiceModel.CommunicationException or even just a System.Exception.

On an unrelated point, note that it isn't wise to arbitrarily 'max out' all of the WCF config settings - see C# WCF - Client/Server - System.OutOfMemory Exception.

Community
  • 1
  • 1
StuartLC
  • 104,537
  • 17
  • 209
  • 285
  • Thanks for the reply. I have done that actually, but in this case i know that service is stopped. I am testing it that way by stopping the service. The question is we have developed the disconnected senario and if service is stoped than it will return the default data but it takes time so i am investigatig is it the openTimeOut which is responsible for it. – Learner Apr 04 '12 at 09:40
0

A TimeSpan value that specifies the interval of time provided for an open operation to complete. This value should be greater than or equal to Zero. The default is 00:01:00.

so what i am understanding from this is that the operation which is already open it should be completed within a minute. Any comment ?? Because i am tesitng it and it takes only 5 seconds to throw the EndPointNotFoundException

Learner
  • 1,490
  • 2
  • 22
  • 35
  • 1
    It's a maximum threshold. If the underlying TCP/IP connection fails in a shorter timeframe (e.g. HTTP 404, 5xx etc) then it the exception will be thrown in less time than the timespan. However, if the server is far away and you have a 10 bits per second network connection to it, you can guarantee that the connection will be timed out at no longer than the time you specify. – StuartLC Apr 04 '12 at 09:55