Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

245
Visualizações
SignalR disconnecting every few minutes after the tab is backgrounded

I'm using SignalR for communication between a Vue.js frontend and dotnet backend.

When you background the frontend tab after a (seemingly random) amount of time the connection gets disconnected. Because I'm using auto reconnect the socket is then reconnected, but then until the tab is re-focused the socket will continue to get disconnected every couple of minutes putting it in a reconnecting loop.

enter image description here

A few things:

  • Seems to happen in all browsers but Firefox
  • When running both the frontend and backend locally, there's no issue
  • Running the frontend locally but backend remotely does cause the issue
  • Neither application are running on IIS
  • Kestrel timeouts have been set to an hour (just in case)
  • The initial disconnect that causes the reconnects to start looping doesn't happen at a consistent time, just somewhere around the 5-10 minute mark
  • No errors are being thrown by either end

Client side code is extremely basic:

 this.connection = new HubConnectionBuilder()
        .withUrl(this.url)
        .withAutomaticReconnect()
        .build()

Server side code is similarly basic:

 public override async Task OnConnectedAsync()
    {
        //Create client code here

        await base.OnConnectedAsync();
    }

    public override async Task OnDisconnectedAsync(Exception exception)
    {
        if(exception != null) _logger.LogErrorToFile(exception.Message);
        _logger.LogInformationToFile($"Client with id: {GetConnectionId()} disconnected.{GetUsername()}");
        await base.OnDisconnectedAsync(exception);
    }
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Chrome made an update earlier this year that stops connections when they are not in focus after about 5 minutes. The issue/fix that Nirbhay commented is actually for the ASP.NET version (2.4.2) and not compatible with .NET CORE. Here is the issue that was raised for .NET CORE - github.com/dotnet/aspnetcore/issues/31079

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda