SignalR connection

Sakanat 2024 0 Reputation points
2024-05-03T23:01:03.9033333+00:00

How can I test the connection of SignalR hub without client
I write this code and do not know how to test to check if there is a problem in my code
here is part of my code that is for signalR in my api:
please tell me how should I do to connect with react.js

builder.Services.AddSignalR(); app.UseHttpsRedirection()

    .UseRouting()

    .UseCors()

    .UseAuthentication()

    .UseAuthorization()

    .UseEndpoints(

        endPoints =>

        {

            endPoints.MapControllers();

            endPoints.MapHub<SignalServer>("/signalServer");

        }

    );
```app.Run();  
  
  
public class SignalServer : Hub

{

```vba
public async Task SendNotification(string userId, string message)

{

    await Clients.User(userId).SendAsync("ReceiveNotification", message);

}
```}
ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
4,228 questions
{count} votes

1 answer

Sort by: Most helpful
  1. JasonPan - MSFT 4,386 Reputation points Microsoft Vendor
    2024-05-06T09:50:57.5333333+00:00

    Hi @Sakanat 2024,

    How can I test the connection of SignalR hub without client

    We can connect the signalr hub by using postman. For more details, you can google it.

    User's image

    I write this code and do not know how to test to check if there is a problem in my code

    Usually we recommend using server-side and client-side logging when developing and debugging.

    please tell me how should I do to connect with react.js

    You can configure the client by using javascript or typescript. And if you want a completely repo for referring, you can search it in github.


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    Best regards,

    Jason

    0 comments No comments