1
我正在使用SignalR.client DLL與使用SignalR的網站進行對話。 當客戶端和站點在同一臺機器上時,它可以很好地工作。 (調用中心方法立即)調用集線器方法在本地網絡上運行緩慢
但是,現在我通過網絡在機器上設置了網站,調用(調用)平均需要2.5秒。 (但工作)
我ping機在< 1ms。
使用Wireshark我看到數據包在2.5秒後發送。
我調試的SignalR.client DLL和它停留在System.Threading.Task水平(這裏稱爲,在HttpHelper.cs)
[SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Justification = "Exceptions are flowed back to the caller.")]
public static Task<Stream> GetHttpRequestStreamAsync(this HttpWebRequest request)
{
try
{
return Task.Factory.FromAsync<Stream>(request.BeginGetRequestStream, request.EndGetRequestStream, null);
}
catch (Exception ex)
{
return TaskAsyncHelper.FromError<Stream>(ex);
}
}
的什麼可能拖慢進程的任何想法?
非常感謝。
ps:我已經使用SignalR聊天示例來重現延遲。
PPS:這是我的測試應用程序的(很簡單)的代碼:
var connection = new HubConnection("http://IP:PORT/SITENAME/");
var myHub = connection.CreateHubProxy("ChatHub");
// Start the connection
connection.Start().Wait();
while (true)
{
string sMsg = string.Format("Hello world from winform! Sent(winform) at {0}", DateTime.Now.ToString("hh:mm:ss.fff"));
Console.WriteLine("Sending data : " + sMsg);
myHub.Invoke("Send", "Winform", sMsg).ContinueWith(task2 =>
{
if (task2.IsFaulted)
{
Console.WriteLine("An error occurred during the method call {0}", task2.Exception.GetBaseException());
}
else
{
Console.WriteLine("Successfully called MethodOnServer at {0}", DateTime.Now.ToString("hh:mm:ss.fff"));
}
});
Thread.Sleep(60*1000);
}
它是一個單一的連接? – davidfowl 2013-03-04 09:48:37
是的,我創建了一個連接。我用代碼 – 2013-03-04 09:53:27
更新主帖子它是一個控制檯應用程序嗎?代碼看起來很好。 – davidfowl 2013-03-04 10:04:46