An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
Hi bright owusu.
To troubleshoot this, can you provide these details?
- How are you sending to the admin in your Hub?
Clients.User(...),Clients.Group(...), orClients.Client(...)? - Are user/admin authenticated (cookies/Identity or JWT)?
- Can you paste:
Program.cs(yourMapHub), the Hub method that sends the message, and the JSHubConnectionBuilder()from the admin page?
Also try checking:
- In the browser open DevTools → Network → WS and check the *bsocket for your hub (e.g.
/chathub). If it’s not 101 Switching Protocols or it keeps disconnecting, the admin isn’t actually connected. - Also check Network for
/chathub/negotiateand its HTTP status/error. - Enable SignalR logging on the client:
const connection = new signalR.HubConnectionBuilder()
.withUrl("/chathub")
.configureLogging(signalR.LogLevel.Information)
.withAutomaticReconnect()
.build();
await connection.start();
console.log("connected", connection.connectionId);
Common issue might be that Clients.Client(x) expects a connectionId, not a userId. If you’re targeting the admin by user id, you usually want Clients.User(adminUserId) (and the user-id claim mapping must match).
Please follow this guide regarding Authentication and authorization in ASP.NET Core SignalR https://learn.microsoft.com/aspnet/core/signalr/authn-and-authz?view=aspnetcore-9.0
I hope that this helps with your problem. Let me know if anything comes up.
If you found my response helpful or informative, I would greatly appreciate it if you could follow this guidance or provide feedback. Thank you.