发生SignalR问题:
关闭websocket时出错: System.Net.WebSockets.WebSocketException(0x80070006):句柄是 无效
我认为问题与此代码有关:
var currentHub = GlobalHost.ConnectionManager.GetHubContext<HubManager>();
currentHub.Groups.Remove(userConnectionId, roomName);
如何解决?
答案 0 :(得分:1)
我遇到了同样的问题,当我向SignalR添加SQL背板时,这种情况就开始发生了,
它与&#34; Freshness&#34;我所做的中心环境是:
/// <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;
}
}
}