In a SignalR hub, I am adding connections to groups in the OnConnected
method:
public override Task OnConnected()
{
this.Groups.Add(this.Context.ConnectionId, "aGroup");
this.Groups.Add(this.Context.ConnectionId, "bGroup");
}
Do I need to manually remove the connection from these groups upon disconnect? Given the pub-sub model, I don't see how I could easily do this, except to keep track of connections and groups in a separate data structure.
I am experiencing a rather large memory leak in an MVC project using SignalR, and am wondering if this could be the culprit.
SignalR version 2 does not have a built-in server API for disconnecting clients. There are plans for adding this functionality in the future. In the current SignalR release, the simplest way to disconnect a client from the server is to implement a disconnect method on the client and call that method from the server.
In the default mode, the app server creates five server connections with Azure SignalR Service. The app server uses the Azure SignalR Service SDK by default. In the following performance test results, server connections are increased to 15 (or more for broadcasting and sending a message to a big group).
SignalR requires that all HTTP requests for a specific connection be handled by the same server process. When SignalR is running on a server farm (multiple servers), "sticky sessions" must be used. "Sticky sessions" are also called session affinity by some load balancers.
No, you don't.
You don't have to explicitly create groups. In effect, a group is automatically created the first time you specify its name in a call to Groups.Add, and it is deleted when you remove the last connection from membership in it.
Source, and read further: http://www.asp.net/signalr/overview/guide-to-the-api/working-with-groups
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