Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SignalR hub Disconnects after 45minutes of connected to Server #59087

Closed
vsfeedback opened this issue Nov 21, 2024 · 1 comment
Closed

SignalR hub Disconnects after 45minutes of connected to Server #59087

vsfeedback opened this issue Nov 21, 2024 · 1 comment
Labels
area-signalr Includes: SignalR clients and servers Author: Migration Bot 🤖 The issue was created by a issue mover bot. The author may not be the actual author.

Comments

@vsfeedback
Copy link

This issue has been moved from a ticket on Developer Community.


I was trying to connect front end and back end to the server, it was connected but when the web app in idle for 45 minutes it gets disconnected, i want my web app to not get disconnect to the SignalR hub, I tried lots of code and read lots of documentation but i cant fix that issue

this was the code i used in my backend server

Starup.CS

services.AddSignalR(hubOptions =>
{
hubOptions.KeepAliveInterval = TimeSpan.FromSeconds(30);
});

app.MapHub<NotificationSignalrHub>(pattern: "/NotificationHub");

SignalRHub.CS

public async Task HandShakeToNotificationHub(UserConnection userConnection)
{
try
{
await Groups.AddToGroupAsync(Context.ConnectionId, GroupName);

    bool isOperationDone = adding the connectionid to the Database;
    if (isOperationDone)
    {
        await Clients.Group(GroupName).SendAsync("HandShakeToNotificationHub", "System", $"{userConnection.UserEmail} has been connected.");
    }
}
catch (Exception)
{
    throw;
}

}

public async Task SendMessage(string message)
{
try
{
var mar = getting the connection id from the Database;
if (mar is not null)
{
await Clients.Group(GroupName).SendAsync("ReceiveNotification", message);
}
}
catch (Exception ex)
{
throw;
}
}

please let me know what to do


Original Comments

Feedback Bot on 11/8/2024, 00:13 AM:

We have directed your feedback to the appropriate engineering team for further evaluation. The team will review the feedback and notify you about the next steps.

@dotnet-issue-labeler dotnet-issue-labeler bot added the area-signalr Includes: SignalR clients and servers label Nov 21, 2024
@dotnet-policy-service dotnet-policy-service bot added the Author: Migration Bot 🤖 The issue was created by a issue mover bot. The author may not be the actual author. label Nov 21, 2024
@BrennanConroy
Copy link
Member

Dupe of #59086

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-signalr Includes: SignalR clients and servers Author: Migration Bot 🤖 The issue was created by a issue mover bot. The author may not be the actual author.
Projects
None yet
Development

No branches or pull requests

2 participants