0

I have the following code to setup a WCF service in code:

namespace Serviceman
{
public class Hostman
{

    public Uri VServicesTCPAddress = new Uri("net.tcp://localhost:8000/v-services");
    public ServiceHost VServicesHost = new ServiceHost(typeof(MyDemoService), new Uri("net.tcp://localhost:8000/v-services"));

    public void ConfigureTcpService()
    {
        NetTcpBinding tcpBinding = new NetTcpBinding();
        ServiceMetadataBehavior sMBehavior = new ServiceMetadataBehavior();
        VServicesHost.Description.Behaviors.Add(sMBehavior);
        VServicesHost.AddServiceEndpoint(typeof(IMetadataExchange),
        MetadataExchangeBindings.CreateMexTcpBinding(), "mex");
        VServicesHost.AddServiceEndpoint(typeof(IAccountsService), tcpBinding, VServicesTCPAddress);
    }

}

}

I have started the service and it's working just fine, but when I connect multiple instances of my client, after some time I receive errors of having used all available channels. The question now is how can I increase the default value for connection pooling limit or even remove that?

Medise
  • 351
  • 1
  • 2
  • 11
  • Is the consumer of the service closing the connection immediately after it gets a response? If not, then the connection won't be available for re-use until it has timed out (which could be minutes). – DeanOC Nov 24 '14 at 02:27
  • Well not, I have not coded it to close, thought WCF takes care of that. So if I close them, is there any chance I face the error again? – Medise Nov 24 '14 at 02:37
  • I view WCF connections in the same way as SQL connections, i.e. close them as quickly as you can. See Enrico Campidoglio's answer in this [question](http://stackoverflow.com/questions/9061923/correct-way-to-close-wcf-4-channels-effectively) for the way that I think you should be coding your client. BTW, I believe that the default WCF max concurrent session count is 100 x No. of server processors (you should be able to check this thru IIS manager assuming ur using IIS). – DeanOC Nov 24 '14 at 03:56

1 Answers1

0

Enable port sharing on your TCP binding like this,

tcpBinding.PortSharingEnabled = true;

Or,

Change maxConnections available on your TCP binding configuration to something of your choice.The default for Max connection is 10 out of the box.

gunvant.k
  • 1,096
  • 1
  • 10
  • 15
  • So, is 'maxConnections' a general limit for all clients connecting to the service or each client has its own number of connections? I mean if I set it to 100 for example, is this the limit for all of them or each client gets 100? – Medise Nov 24 '14 at 02:32