SignalR に関する問題/知識不足があるため、ハブ クライアント/サーバーがあり、別の GUI アプリが断続的にハブに接続してメッセージを送信します。接続を維持するか、メッセージの送信後に切断する必要があります。
私が遭遇する問題は、常に最初のメッセージを送信するが、2 番目のメッセージの送信が停止することです。これがなぜなのかわかりません。
public void SignalR_Connect(string message)
{
var connection = new HubConnection("http://site/signalr");
IHubProxy myHub = connection.CreateProxy("chat");
Console.WriteLine("Connection state is : " + connection.State.ToString());
connection.Start().ContinueWith(task =>
{
Console.WriteLine("Attempting to Connect");
if (task.IsFaulted)
{
Console.WriteLine("There was an error opening the connection:{0}", task.Exception.GetBaseException());
}
else
{
Console.WriteLine("Client Connected");
}
}).Wait();
//Sending message
myHub.Invoke("Send", message).ContinueWith(task =>
{
if (task.IsFaulted)
{
Console.WriteLine("There was an error calling send: {0}", task.Exception.GetBaseException());
Console.WriteLine(task.Status.ToString());
}
else
{
Console.WriteLine("Send Complete.");
}
}).Wait();
//Back round to get the next message.
//Method grabs next message in the MSMQ and sends it to SignalR_Connect method.
Read_Queue();
}
私は connection.stop() を試しました。ハブに close メソッドを実装して、クライアントが GlobalHost.Configuration.ConnectionTimeout を離れて設定していることをサーバーに通知しますが、それでも同じ動作が得られます。