This SignalR problem occurs:
Error while closing the websocket: System.Net.WebSockets.WebSocketException (0x80070006): The handle is invalid
I think that the problem is linked to this code:
var currentHub = GlobalHost.ConnectionManager.GetHubContext<HubManager>();
currentHub.Groups.Remove(userConnectionId, roomName);
How can it be fixed?
I have had the same problem , This started happening when I added an SQL Backplane to signalR,
It has to do with the "Freshness" of the hub context what I did is this :
/// <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;
}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With