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 #59086

Open
vsfeedback opened this issue Nov 21, 2024 · 2 comments
Open

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

vsfeedback opened this issue Nov 21, 2024 · 2 comments
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. Needs: Author Feedback The author of this issue needs to respond in order for us to continue investigating this issue.

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

hubOptions.KeepAliveInterval = TimeSpan.FromSeconds(30);

Did you also change the ServerTimeout on the client side?

Get logs so we can see why the connection disconnected:
https://learn.microsoft.com/aspnet/core/signalr/diagnostics?view=aspnetcore-9.0

@BrennanConroy BrennanConroy added the Needs: Author Feedback The author of this issue needs to respond in order for us to continue investigating this issue. label Nov 21, 2024
Copy link
Contributor

Hi @vsfeedback. We have added the "Needs: Author Feedback" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

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. Needs: Author Feedback The author of this issue needs to respond in order for us to continue investigating this issue.
Projects
None yet
Development

No branches or pull requests

2 participants