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

Issue with Microsoft.AspNet.SignalR.Client hanging/crashing app after app being in background for 10 + minutes #4702

Open
JoeyIreland opened this issue Mar 22, 2024 · 0 comments

Comments

@JoeyIreland
Copy link

I'm encountering a problem with my ASP.NET SignalR client where, upon reopening the app after it has been in the background for around 20 minutes, the client hangs when it tries to connect. This eventually leads to either freezing the app or causing it to crash entirely.

Here's a snippet of the relevant code:

if (SignalRClient != null)
{
    await Connect(_chatGuid.ToString());
}
await SignalRClient.JoinGroup(_chatGuid.ToString(), App.entityClientGuid.ToString(), App.oSType);

which both of these methods do the following:

 public async Task Connect()
    {
        try
        {
            await _connection.Start();
        }
        catch (Exception ex)
        {
            Console.WriteLine($"Failed to connect: {ex.Message}");
            await Reconnect();
        }
    }

public async Task JoinGroup(string roomName, string entityGuid, string deviceType)
    {
        try
        {
            await _proxy.Invoke("JoinGroup", roomName, entityGuid, deviceType);
        }
        catch (Exception ex)
        {
            Console.WriteLine($"Failed to join: {ex.Message}");
        }
    }

I'm using Microsoft.AspNet.SignalR.Client for real-time communication in my application. It works flawlessly under normal circumstances, but the issue arises when the app has been inactive in the background for approximately 20 minutes. Upon reopening the app, the SignalR client seems to struggle to connect, causing the app to become unresponsive or crash.

I've tried debugging the issue, but I'm unable to pinpoint the exact cause. It seems like the connection process gets stuck or times out after the app has been in the background for an extended period.

Could this be related to some kind of timeout setting in SignalR or perhaps a network-related issue? Any insights or suggestions on how to troubleshoot and resolve this issue would be greatly appreciated. Thank you!

using Xamarin Forms with Microsoft.AspNet.SignalR.Client 2.4.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant