0

I create Hub class, when new user connect call function OnConnected:

public class ReportChat : Hub
{
    public async Task OnConnected()
    {
        string name = Context.User.Identity.Name;
        await Groups.AddAsync(Context.ConnectionId, name);
    }
}

But when connected second user, or sometimes, when I refresh page SignalR generate error on frontend: No Connection with that ID.

Using transport protocol: signalR.TransportType.LongPolling

connection = new signalR.HubConnection("/ReportJson", { transport: signalR.TransportType.LongPolling });
        connection.on('SendReport',
            function(data) {
                console.log(data.value.name);
            });
        connection.start().then(() => {
            connection.invoke('OnConnected');
            hubConnectionEstablished = true;
        });

1 Answers1

2

When you refresh your page you are disconnecting and reconnecting and therefore will be generating a new connectionId for that client. You can verify that this is happening by setting breakpoints in your OnConnected and OnDisconnected methods.

Mikael Mengistu
  • 332
  • 1
  • 6