Search code examples
c#wcfproxychannelfactory

Does ChannelFactory.CreateChannel() actually open connection?


May be this is very obious but after doing google alot, couldn't reach to any conclusion.

I want to know "does ChannelFactory.CreateChannel() actually open connection or it just return something and actual connection will be open the time of method call. How long this connection will be alive if I don;t close it."


Solution

  • Good question. When I wonder about something like that, I am just reading the source code of .Net at there.

    CreateChannel method calls the Open method internally. If the CommunicationState is not equal to Opened then Open method executing with DefaultOpenTimeout.

    DefaultOpenTimeout is configured by endpoint binding configuration.

    You can see the source code.