Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/api/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 与API的信令连接_C#_Api_Signalr_Signalr Hub_Signalr.client - Fatal编程技术网

C# 与API的信令连接

C# 与API的信令连接,c#,api,signalr,signalr-hub,signalr.client,C#,Api,Signalr,Signalr Hub,Signalr.client,我在c#中设置了一个web api。它检查它是否仍然与信号机连接,并根据需要执行代码。这是我的情况: if (hubConnection != null && hubConnection.State == Microsoft.AspNet.SignalR.Client.ConnectionState.Connected) { hubProxy.Invoke("hubMethod", hubParams); } else { hubConnection = new

我在c#中设置了一个web api。它检查它是否仍然与信号机连接,并根据需要执行代码。这是我的情况:

if (hubConnection != null && hubConnection.State == Microsoft.AspNet.SignalR.Client.ConnectionState.Connected)
{

    hubProxy.Invoke("hubMethod", hubParams);
}
else
{
    hubConnection = new HubConnection(ConfigurationManager.AppSettings["signalRPath"].ToString());
    hubProxy = hubConnection.CreateHubProxy("ChatHub");
    hubConnection.Start().Wait();
    hubProxy.Invoke("hubMethod", hubParams);
}
问题是,当我重新启动signalR服务器时,我的API继续从prev connection ID调用hubMethod,而不是使用signalR创建新的连接ID


如果我提供的信息不够,请让我知道

重新启动时,您是否将连接ID保留在服务器上的某个位置进行管理?@farrukhshubani我不这样认为。它基本上只是一个需要保持打开状态的连接,或者在服务器重新启动时重新连接。。