hello to all
I have develop a silverlight chat application. In a single window load more than one chat windows at same time and every chat windo create a new connection to wcf duplex service. But after every 10 chat windows it disconnect from wcf and work stuck off. Im code some for throttling option but they don't work. this is my code:-
public class PollingDuplexServiceHostFactory : ServiceHostFactoryBase
{
public override ServiceHostBase CreateServiceHost(string constructorString,
Uri[] baseAddresses)
{
return new PollingDuplexSimplexServiceHost(baseAddresses);
}
}
/// <summary>
/// PollingDuplexServiceHostFactory
/// </summary>
class PollingDuplexSimplexServiceHost : ServiceHost
{
public PollingDuplexSimplexServiceHost(params System.Uri[] addresses)
{
InitializeDescription(typeof(JakayaChatService), new UriSchemeKeyedCollection(addresses));
Description.Behaviors.Add(new ServiceMetadataBehavior());
var throttle = Description.Behaviors.Find<ServiceThrottlingBehavior>();
if (throttle == null)
{
throttle = new ServiceThrottlingBehavior
{
MaxConcurrentCalls = 1000,
MaxConcurrentInstances = 1000,
MaxConcurrentSessions = 1000
};
Description.Behaviors.Add(throttle);
}
}
protected override void InitializeRuntime()
{
PollingDuplexBindingElement pdbe = new PollingDuplexBindingElement()
{
ServerPollTimeout = TimeSpan.FromSeconds(05),
InactivityTimeout = TimeSpan.FromSeconds(3600)
};
// Add an endpoint for the given service contract.
this.AddServiceEndpoint(
typeof(IJakayaChatService),
new CustomBinding(
pdbe,
new BinaryMessageEncodingBindingElement(),
new HttpTransportBindingElement()),
"");
// Add a metadata endpoint.
this.AddServiceEndpoint(
typeof(IMetadataExchange),
MetadataExchangeBindings.CreateMexHttpBinding(),
"mex");
base.InitializeRuntime();
}
}