OnConnected hitting not stable

Asked by At

I have a ASP.NET SignalR project version 2.4. I created a Hub on signalr server (using webapp) then override Onconnected method like that:

  public override Task OnConnected()
        _log.Debug("OnConnected: " + Context.ConnectionId);

        Interlocked.Increment(ref _usersCount);

        var user = new UserDataDto()
            ConnectionId = Context.ConnectionId,
            ClientId = Context.QueryString["clientId"],
            GroupName = Context.QueryString["groupName"],
            Token = Context.QueryString["access_token"],
            RefreshId = Context.QueryString["refresh_token"],
            MachineId = Context.QueryString["machineId"],
            SystemName = Context.QueryString["systemName"],
            ConnectedAt = DateTime.Now

        _users[Context.ConnectionId] = user;

        _log.Debug("AddGroup: AddGroup");

        AddGroup(Context.ConnectionId, Context.QueryString["systemName"], Context.QueryString["groupName"], Context.QueryString["machineId"], Context.QueryString["clientId"]);

        return base.OnConnected();

Hub client:

  var connection = $.hubConnection(PUlSE_SETTINGS.signalUri);
    me.signalR.logging = true;
    connection.qs = {
        'server': false,
        'access_token': sessionFactory.get('access_token'),
        'refresh_token': sessionFactory.get('refresh_token'),
        'clientId': sessionFactory.get('clientId'),
        'groupName': me.groupName,
        'systemName': me.systemName,
        'machineId': '',
        'role': sessionFactory.get('role')

    var chatHub = connection.createHubProxy(PUlSE_SETTINGS.hubName);
    connection.start().done(function () {

When client is connected, connection is started success (console.log showed state 1), But hasn't any action hit into OnConnected method. So we can't received any data that is send from signalr server:

Clients.All.SendMessage(machineId, json);

Any suggestion for this issue?

0 Answers