2009-10-05 64 views
0

我已经写了一篇使用NetTcpBinding进行通信的应用程序并向客户推出了该应用程序。WCF Net Tcp绑定服务器拒绝超过5个连接

我有一个服务器应用程序接受来自客户端的订阅请求,然后将数据推送到客户端。

客户端在服务器连接了5个客户端的网站上看到一个问题,它拒绝了。

有没有人见过这种行为?有谁知道可能是什么原因造成的?它适用于较少的用户。

我试图自己诊断此刻,但我是新来的WCF,所以我想知道是否有这种问题的一些常见的解决方案?

我碰到下面的堆栈跟踪(Sanitzes删除客户端名称和产品名称):

2009-09-30 13:03:16,308 [1] ERROR [(null)] - Failed to subscribe to the VDN server, there was no server listening for connections at the configured URI 
System.ServiceModel.EndpointNotFoundException: Could not connect to net.tcp://server:4000/VDNService. The connection attempt lasted for a time span of 00:00:01.0312236. TCP error code 10061: No connection could be made because the target machine actively refused it 10.65.1.42:4000. ---> System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it 10.65.1.42:4000 
    at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress) 
    at System.Net.Sockets.Socket.Connect(EndPoint remoteEP) 
    at System.ServiceModel.Channels.SocketConnectionInitiator.Connect(Uri uri, TimeSpan timeout) 
    --- End of inner exception stack trace --- 

Server stack trace: 
    at System.ServiceModel.Channels.SocketConnectionInitiator.Connect(Uri uri, TimeSpan timeout) 
    at System.ServiceModel.Channels.BufferedConnectionInitiator.Connect(Uri uri, TimeSpan timeout) 
    at System.ServiceModel.Channels.ConnectionPoolHelper.EstablishConnection(TimeSpan timeout) 
    at System.ServiceModel.Channels.ClientFramingDuplexSessionChannel.OnOpen(TimeSpan timeout) 
    at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout) 
    at System.ServiceModel.Channels.ServiceChannel.OnOpen(TimeSpan timeout) 
    at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout) 
    at System.ServiceModel.Channels.ServiceChannel.CallOpenOnce.System.ServiceModel.Channels.ServiceChannel.ICallOnce.Call(ServiceChannel channel, TimeSpan timeout) 
    at System.ServiceModel.Channels.ServiceChannel.CallOnceManager.CallOnce(TimeSpan timeout, CallOnceManager cascade) 
    at System.ServiceModel.Channels.ServiceChannel.EnsureOpened(TimeSpan timeout) 
    at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout) 
    at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs) 
    at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation) 
    at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message) 

Exception rethrown at [0]: 
    at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) 
    at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) 
    at ClientLib.IServer.Subscribe(List`1 groups) 
    at ClientLib.Client.Subscribe(List`1 groupNames) 

回答

4

的几个问题前面:

  • 在您的服务器端,什么是你的配置看喜欢?
  • 服务器运行的是什么操作系统? (一些操作系统版本/版本有限制)
  • 你如何在你的服务器上托管你的WCF服务? (IIS与自托管)

基本上可以调整使用ServiceThrottling行为的并发连接数,你可以定义

  • 并发呼叫最大数量
  • 最大并发数会话(包括TCP/IP传输会话)
  • 服务类实例的最大数目

要配置,试试这个:

<serviceBehaviors> 
    <behavior name="throttledService"> 
     <serviceThrottling 
      maxConcurrentCalls="10" 
      maxConcurrentInstances="10" 
      maxConcurrentSessions="10"/> 
    </behavior> 

,当然还有,你的服务配置便要引用行为的配置。

没有一个默认为5,但: - 但在你的情况下,我会尝试将所有的设置调整到25或者什么,只是看看是否有任何区别,然后调整到你的需要(和监控服务器的CPU和内存负载)

马克

UPDATE:
可以肯定也为此在代码 - 这样的事情(在服务器端,你实例您ServiceHost类! ,如果你自己主机):

using (ServiceHost host = new ServiceHost(typeof(MyWCFService))) 
{ 
    ServiceThrottlingBehavior stb = new ServiceThrottlingBehavior(); 
    stb.MaxConcurrentCalls = 25; 
    stb.MaxConcurrentInstances = 25; 
    stb.MaxConcurrentSessions = 25; 

    host.Description.Behaviors.Add(stb); 

    host.Open(); 

    ... 
} 
+0

这个应用程序没有WCF配置文件,因为我手动编写了基于教程的WCF组件。 我会看看是否有可能在代码中更改这些变量的方法。 – 2009-10-05 10:42:34

+0

该绑定具有我希望尝试的MaxConnections属性。谢谢你的帮助。 – 2009-10-05 10:58:34

+0

好,但你是自我托管(控制台应用程序,NT服务)或托管在IIS? – 2009-10-05 11:49:50