2
這怎麼可能?我認爲一個方法的電話是火,忘了。該方法被標記爲單向。回調併發模式設置爲Multiple,並且回調類的UseSychronizationContext設置爲false。發送的數據不超過1KB,但每次我同時發送大約30-40條小信息時,呼叫開始阻塞,最終其中一些超時。我已經以大約16000 /秒的速度對我的客戶端 - >服務器調用進行了基準測試。當我嘗試回覆客戶端時,我只能每秒約2次,並且這是在OneWay呼叫中!WCF單向回調計時?
服務器我綁定配置看起來像這樣:
<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.
}
}
也許節流也用於回調?你使用的是什麼版本的.NET框架? – 2011-04-13 18:02:11
我正在使用.net 4.0。我注意到,在第一批併發呼叫中需要很長時間,有時連接甚至丟失。下一批併發呼叫速度很快。這裏有一些JIT編譯問題嗎?我怎樣才能爲此編碼?我已經限制設置得很高: <行爲NAME = 「高通量」> serviceBehaviors> –
2011-04-13 18:18:10
什麼,甚至是陌生人是,如果我的回調方法簡單地返回回調是快速的。但是,如果我在回調方法中進行睡眠,則服務器上的回調調用會掛起,就好像它正在等待客戶端一樣。但是,這些是單向通話,所以服務器爲什麼要等待客戶端回調返回? – 2011-04-13 21:03:55