Use unique connection groups in .NET 4 client per DefaultHttpClient instance #2452

Closed
davidfowl opened this Issue Aug 21, 2013 · 1 comment

3 participants

@davidfowl
SignalR member

Right now we have 2 static groups for long running and short running requests. You'll likely run into issues when you're using several connections in the same process. To achieve what we do with HttpClient, we need to generate a unique group name per instance of the IHttpClient.

Instead of https://github.com/SignalR/SignalR/blob/dev/src/Microsoft.AspNet.SignalR.Client/Http/DefaultHttpClient.cs#L14, we can do

public class DefaultHttpClient : IHttpClient
{
    private string _shortRunningGroup;
    private string _longRunningGroup;

    private IConnection _connection;

    public DefaultHttpClient()
    {
        string id = Guid.NewGuid().ToString();
        _shortRunningGroup = "SignalR-short-running-" + id;
        _longRunningGroup = "SignalR-long-running-" + id;
    }
    ....
}
@halter73 halter73 was assigned Aug 21, 2013
@gustavo-armenta

tested a LongPolling client sending messages on four threads. All "/send" requests are sent using the shortRunningGroup while all "/poll" use the longRunningGroup. Messages are echoed and received interleaved as expected

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment