我有同樣的問題,這開始發生時,我添加了一個SQL背板signalR,
它與我所做的輪轂方面的「新鮮度」做的是:
/// <summary>
/// In case a backplane is used (in case of load balancer) , the instance should always be taken fresh
/// if no backplane is used no need to refresh the instance on each invocation
public class HubContextService
{
bool BackplaneUsed { get; set; }
IHubContext _context = null;
public HubContextService(bool isBackPlaneUsed = true)
{
BackplaneUsed = isBackPlaneUsed;
}
public IHubContext HubContext
{
get
{
if (BackplaneUsed)
{
return GlobalHost.ConnectionManager.GetHubContext<HubManager>();
}
else
{
if (_context == null)
{
_context = GlobalHost.ConnectionManager.GetHubContext<HubManager>();
}
return _context;
}
}
set
{
_context = value;
}
}
}
我偶爾在我的「單元」測試中看到這些(我沒有清楚地關閉連接)。 –