0

My solution contains two projects: WCF services and WCF client. The order of launching:

enter image description here

When I manually launch my service and later my client it works fine. But if I do the same through IDE in the Debug mode then time of time I get the exception:

An unhandled exception of type System.ServiceModel.EndpointNotFoundException occurred in mscorlib.dll

Additional information: Listening on net.pipe://localhost/ wasn't executed by any ending point who could accept the message. Among other causes it could be caused by the wrong address or action of SOAP. For more details see in the description of InnerException (if is available).

But my client's Config-file contains timeout settings:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <startup> 
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6" />
    </startup>
    <system.serviceModel>
        <bindings>
          <netNamedPipeBinding>
            <binding
                     closeTimeout="00:30:30"
                     openTimeout="00:30:30"
                     receiveTimeout="00:30:30"
                     sendTimeout="00:30:30"/>
          </netNamedPipeBinding>
        </bindings>
        <client>
          <endpoint name="pipe1"
                    address="net.pipe://localhost"
                    binding="netNamedPipeBinding"
                    contract="ServiceReference1.IContent"/>

          <endpoint name="pipe2"
                    address="net.pipe://localhost"
                    binding="netNamedPipeBinding"
                    contract="ServiceReference1.IMessages"/>
        </client>
    </system.serviceModel>
</configuration>

Why the exception occur time of time in the Debug mode?

UPD

Additional variant of the decission:

#if DEBUG
            System.Threading.Thread.Sleep(1000);
#endif
Andrey Bushman
  • 11,712
  • 17
  • 87
  • 182
  • I guess the client is trying to connect too soon. You could surround the connecting code with some retry mechanism (i.e. wait for x milliseconds and try again, repeat y times, throw exception when connecting does not succeed after y tries). – venerik Apr 16 '16 at 14:07
  • Probably related to [this question](http://stackoverflow.com/questions/340521/how-can-i-make-named-pipe-binding-reconnect-automatically-in-wcf). – Jan Köhler Apr 16 '16 at 14:08
  • but the exception occurs earlier than 30 seconds. – Andrey Bushman Apr 16 '16 at 14:09

1 Answers1

0

They are not actually ignored, it is the expected behaviour :

Note: if a connection to the service endpoint cannot be established at all (i.e. the service is not reachable), WCF does not throw a TimeoutException, instead, the framework throws an EndpointNotFoundException – immediately.

I am not sure whether there is a way to do it properly (at least I can't find anything standard - Time taken to throw EndPointNotFoundException), but you can always create your own on-error reinitialization mechanism (the simplest, but not the best solution is to just catch the EndpointNotFoundException and try to reinitialize the client later).

Community
  • 1
  • 1
Eugene Podskal
  • 10,270
  • 5
  • 31
  • 53