0

Silverlight チャット アプリケーションを開発しました。1 つのウィンドウで複数のチャット ウィンドウを同時にロードし、すべてのチャット ウィンドウが wcf duplex サービスへの新しい接続を作成します。しかし、10 チャット ウィンドウごとに wcf から切断され、動作が停止します。調整オプションのコードをいくつか書いていますが、機能しません。これは私のコードです:-

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();

    }
}
4

1 に答える 1

0

10 の接続制限は、一般的にオペレーティング システムに起因します。たとえば、Windows XP には 10 接続の制限がありますが、サーバー オペレーティング システムでは、運用環境でさらに多くの接続が許可されます。とはいえ、問題は開発環境に限定されている可能性があり、ハイエンド OS にデプロイすると解消されます。

MS からのメモ: Windows XP Professional の場合、ネットワーク経由で同時に接続できる他のコンピューターの最大数は 10 です。この制限には、すべてのトランスポートとリソース共有プロトコルの組み合わせが含まれます。Windows XP Home Edition の場合、ネットワーク経由で同時に接続できる他のコンピューターの最大数は 5 台です。この制限は、システムがホストできる他のコンピューターからの同時セッションの数です。この制限は、リモート コンピューターから接続する管理ツールの使用には適用されません。

IIS 接続の制限と最適化 http://blogs.msdn.com/david.wang/archive/2006/04/12/HOWTO-Maximize-the-Number-of-Concurrent-Connections-to-IIS6.aspx

于 2009-08-12T14:22:15.627 に答える