Reputation: 2835
I have a WCF serve that I've configured to use serviceThrottling, however this does not seem to be working.
I have a mult-threaded client calling this service @
http://localhost:7778/test/sleep?sleep=1000
and the server seems to ignore the max??? settings in the WCF config.
What I'm really trying to do is increase the number of concurent connections, but it doesn't seem that I'm effecting the settings at all.
My server is hosted as follows:
WebServiceHost zHost = new WebServiceHost(typeof (Service1));
zHost.Open();
Console.WriteLine("Started");
Console.ReadLine();
zHost.Close();
The App.config setup is as follows:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<system.net>
<connectionManagement>
<add address="*" maxconnection="65535"/>
</connectionManagement>
</system.net>
<system.serviceModel>
<standardEndpoints />
<behaviors>
<endpointBehaviors>
<behavior name="NewBehavior0">
<webHttp />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="NewBehavior0">
<serviceThrottling maxConcurrentCalls="1" maxConcurrentSessions="1" maxConcurrentInstances="1" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service name="WCF_REST_TEST_1.Service1">
<endpoint address="/test" behaviorConfiguration="NewBehavior0" binding="webHttpBinding" bindingConfiguration="" contract="WCF_REST_TEST_1.IService1" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:7778" />
</baseAddresses>
</host>
</service>
</services>
</system.serviceModel>
</configuration>
Where Service1 is setup as follows:
[ServiceContract]
public interface IService1
{
[WebGet(UriTemplate = "sleep?sleep={value}", ResponseFormat = WebMessageFormat.Json)]
[OperationContract]
CompositeType sleep(int value);
}
and
public class Service1 : IService1
{
public CompositeType sleep(int sleep)
{
Stopwatch sw = new Stopwatch();
sw.Start();
if (sleep > 0)
{
try
{
logger.Log(LogLevel.Info, "Sleep Request recieved: {0}ms", sleep);
Thread.Sleep(sleep);
}
catch (Exception ex)
{
logger.Log(LogLevel.Error, "Error. {0} - {1}", ex.Message, ex.InnerException);
}
}
else
{
logger.Log(LogLevel.Info, "No Sleep value supplied");
}
sw.Stop();
CompositeType zTest = new CompositeType();
zTest.BoolValue = true;
zTest.StringValue = "Some String 2" + sleep;
//zTest.RemoteResponse = responseFromServer;
zTest.RemoteTime = sw.ElapsedMilliseconds;
return zTest;
}
}
Upvotes: 0
Views: 1031
Reputation: 4778
By default InstanceContextMode
is PerCall
, so you have to setup maxConcurrentCalls
and maxConcurrentInstances
Looks like you config file is wrong because only one call is supported
<serviceThrottling maxConcurrentCalls="1" maxConcurrentSessions="1" maxConcurrentInstances="1" />
For example
<system.serviceModel>
<services>
<service behaviorConfiguration="ServiceProviderBehavior"
name="ServiceProvider">
<endpoint address="http://localhost:5060/" binding="webHttpBinding"
behaviorConfiguration="Web" contract="ServiceContracts.IService" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="ServiceProviderBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceThrottling maxConcurrentCalls="250" maxConcurrentInstances="250" />
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="Web">
<webHttp />
</behavior>
</endpointBehaviors>
</behaviors>
</system.serviceModel>
Upvotes: 0