我们在Application中使用SignalR。有一个例外类型:
集线器服务器无法启动。消息:发生一个或多个错误。 堆栈跟踪: System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions) System.Threading.Tasks.Task.Wait(Int32毫秒超时, 的CancellationToken cancelToken() System.Threading.Tasks.Task.Wait()在 ProjectName.TryStartHub(对象来源,ElapsedEventArgs e)
当我们在系统中进行本地测试时没有错误。当我们使用ARR部署它时。那么就有一个例外是仅仅因为ARR。同时我们也删除了ARR,然后尝试了它。但是它不适用于ARR。
代码正确,但是SignalR带有ARR的配置问题。
public void InitializeHub()
{
appLog.Write("Initializing Hub Server");
IHubProxy _hub;
var querystringData = new Dictionary<string, string>();
querystringData.Add("Key", "key1");
hypervisorConnection = new HubConnection("url", querystringData);
_hub = hConnection.CreateHubProxy("Hub");
_hub.On<HypervisorCommand>("ExecuteHypervisorCommand", x => ExecuteHypervisorCommand(x));
#region Initialize Hub Timer
hHubTimer = new System.Timers.Timer();
hHubTimer.Elapsed += new ElapsedEventHandler(TryStartHub);
hHubTimer.AutoReset = false;
hHubTimer.Interval = 1000;
hHubTimer.Enabled = true;
hHubTimer.Start();
#endregion
}
private void TryStartHub(object source, ElapsedEventArgs e)
{
try
{
if (hConnection.State != ConnectionState.Connected)
{
hConnection.Start().Wait();
appLog.Write("Hypervisor Hub server started.");
}
}
catch (Exception ex)
{
appLog.Write("Hub Server was unable to start. Message:" + ex.Message + "\n Stack trace:" + ex.StackTrace);
}
hHubTimer.Interval = 30000;
hHubTimer.Start();
}