How do I broadcast a message as soon as a client connects? I have tried using Clients.All.SendAsync in OnConnectedAsync but it does nothing.
This is definitely possible. I do this in a few of my hubs. There may be an issue with the way you have set up the OnConnectedAsync method perhaps? Maybe you could share what your hub and client look like?
Mine looks something like this:
public async override Task OnConnectedAsync()
{
// do work with database regarding user who just connected
// Send connection id of user who just connected to all clients
await Clients.All.SendAsync("UserConnected", Context.ConnectionId);
await base.OnConnectedAsync();
}