silverlight 在 10 个连接后断开与 wcf 双工的连接

发布于 2024-08-01 20:20:25 字数 2050 浏览 4 评论 0原文

我开发了一个 silverlight 聊天应用程序。 在一个窗口中同时加载多个聊天窗口,每个聊天窗口都会创建一个到 wcf 双工服务的新连接。 但每 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();

    }
}

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

    }
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

扎心 2024-08-08 20:20:25

10 个连接限制通常归因于操作系统。 例如,Windows XP 有 10 个连接限制,而服务器操作系统在生产环境中允许更多连接。 也就是说,这个问题可能仅限于您的开发环境,当部署到更高端的操作系统时就会消失。

MS 的注释:
对于 Windows XP Professional,允许通过网络同时连接的其他计算机的最大数量为 10 台。 此限制包括所有传输和资源共享协议的组合。 对于 Windows XP Home Edition,允许通过网络同时连接的其他计算机的最大数量为五台。 此限制是系统允许托管的其他计算机的同时会话数。 此限制不适用于使用从远程计算机连接的管理工具。

IIS 连接限制和优化
http://blogs.msdn.com/david.wang/archive/2006/04/12/HOWTO-Maximize-the-Number-of-Concurrent-Connections-to-IIS6.aspx

The 10 connection limit is commonly attributed to the operating system. Windows XP for example has a 10 connection limit, wheras server operating systems will allow for many more in a production environment. That said, the issue may be confined to your dev env, and go away when deployed to a higher end OS.

Notes From MS:
For Windows XP Professional, the maximum number of other computers that are permitted to simultaneously connect over the network is ten. This limit includes all transports and resource sharing protocols combined. For Windows XP Home Edition, the maximum number of other computers that are permitted to simultaneously connect over the network is five. This limit is the number of simultaneous sessions from other computers the system is permitted to host. This limit does not apply to the use of administrative tools that attach from a remote computer.

IIS Conneciton Limits and Optimization
http://blogs.msdn.com/david.wang/archive/2006/04/12/HOWTO-Maximize-the-Number-of-Concurrent-Connections-to-IIS6.aspx

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文