私はSilverlightチャットアプリケーションを開発しました。 1つのウィンドウで同時に複数のチャットウィンドウをロードし、すべてのチャットウィンドウでwcfデュプレックスサービスへの新しい接続を作成します。しかし、10のチャットウィンドウごとにwcfから切断され、仕事は止まってしまいます。 Imはいくつかの絞り込みオプションをコードしていますが、機能しません。これは私のコードです: -10コネクション後にSilverlightがwcf duplexから切断されました
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();
}
}