2

这怎么可能?我认为呼叫的一种方式是触发并忘记。该方法被标记为单向。回调并发模式设置为Multiple,回调类的UseSychronizationContext设置为false。发送的数据不超过 1KB,但每次我同时发送大约 30-40 条小消息时,调用开始阻塞,最终其中一些超时。我以大约 16000/秒的速度对我的客户端-> 服务器调用进行了基准测试。当我尝试回拨给客户时,我每秒只能召集大约 2 个,而这在 OneWay 呼叫中!

我的服务器绑定配置如下所示:

<system.serviceModel>
<bindings>
  <netNamedPipeBinding>
    <binding name="netNamedPipeBinding1" receiveTimeout="23:00:00" maxReceivedMessageSize="1048576" maxBufferPoolSize="1048576" maxConnections="500">
      <readerQuotas maxStringContentLength="99999999" maxArrayLength="9999999" maxBytesPerRead="999999"/>
      <security mode="None"/>
    </binding>
  </netNamedPipeBinding>
</bindings>
<behaviors>
  <serviceBehaviors>
    <behavior name="highThroughPut">
      <serviceThrottling maxConcurrentCalls="3000" maxConcurrentInstances="3000" maxConcurrentSessions="3000"/>
    </behavior>
  </serviceBehaviors>
</behaviors>
<services>
  <service name="OLII.Apps.Services.Data.DataServices.DataService" behaviorConfiguration="highThroughPut">
    <endpoint bindingConfiguration="netNamedPipeBinding1" address="net.pipe://localhost/DataListener" binding="netNamedPipeBinding" contract="OLLI.Apps.Services.ProxyClients.DataServerProxyClient.IDataListenerService"/>
   </service>
</services>
</system.serviceModel>

我的回调合约如下所示:

   public interface IDataCallbackClient
    {
        [OperationContract(IsOneWay = true)]
        void GetData(string file, int id);
    }

我的客户端回调类如下所示:

   [CallbackBehavior(ConcurrencyMode = ConcurrencyMode.Multiple, UseSynchronizationContext = false)]
    public class DataCallback : IDataCallbackClient
    {
public void GetData(string file, int id)
{
//If I put Thread.Sleep(5000);  When the server calls this method, the first few go through, and subsequent calls block.  If I do a return statement here, all the calls go through really fast on the server side.
//Does some processing with file and id.  It then goes back to server with data.
}
}
4

1 回答 1

2

我想到了。我对我的服务的调用阻塞了进程中的线程池并使其饿死。我还从我的 wcf 服务内部调用线程池调用,这是一种不好的做法,因为这些方法是在线程池本身上调用的。看起来当您进行单向调用并且线程池处于饥饿状态时,单向调用将超时,因为它没有要执行的线程。谢谢

于 2011-04-14T19:07:47.960 回答