SignalR clients not receiving messages

Viewed 23

Absolutely stumped for days here.

I have an AspNetCore.SignalRCore hub where I create a group for each connected device i.e.

public async Task<bool> RegisterDeviceOnGroup(string identifier) { //identifier is mobile number
            try {
                var connectionId = GetConnectionId();
                await Groups.AddToGroupAsync(connectionId, identifier);
                return true;
            } catch (Exception ex) {
                return false;
            }
        }

I can log and see that the clients groups are being created.

Then I send a message from a controller (with the HubContext injected) as follows:

await _hubContext.Clients.Group(identifier).SendAsync("HandleMessage", args);

I also send:

await _hubContext.Clients.All.SendAsync("HandleMessage", args);

(just for test purposes)

I log these interactions on the server and am happy that they are being hit BUT after a short while (a few minutes) the devices stop receiving the messages.

It's almost as if the HubContext has lost the groups. Is that a possibility?

I have tried storing the identifiers in memory and in a DB but regardless after a short period devices no longer receive messages. I am running trace level debug and can see that the devices are still connected.

Any ideas will help?

0 Answers
Related