SignalR.client DLLを使用して、SignalRを使用してWebサイトと対話しています。クライアントとサイトが同じマシン上にある場合、これは完全に機能します。(ハブメソッドの呼び出しは即時です)
ただし、ネットワークを介してマシン上にサイトをセットアップしたので、呼び出し(呼び出し)には平均2.5秒かかります。(しかし仕事)
マシンに1ms未満でpingを実行します。
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);
}