Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

262
Vistas
How to catch 401 Unauthorized from SignalR after token expired

I have built an page that gets real-time data from my azure functions backend via SignalR. Lets say i stay on the page, watching the data for 1 hour, and i might get a disconnect, the signalr client will try to reconnect automatically, this works fine. But when it tries to reconnect the jwt token might have expired and a 401 is throw from the signalr client.

Is there any way to catch this 401 from the signalr client when a reconnect is fired?

Many people seems to use .onclose() but will not work for me, or fetching a new jwt token every time they connect, i guess this might be the way i need to proceed, but i prefer if it would be possible to catch it instead, that would be a better fix in my opinion.

var connection = new signalR.HubConnectionBuilder()
                .configureLogging(signalR.LogLevel.Information)
                .withUrl(config.default.hostname + "/api/v1/core/signalr",
                    { accessTokenFactory: () => store.state.accessToken })
                .withAutomaticReconnect([0, 0, 10000])
                .build();

connection.start();

Hope you understand what I'm looking for here! Cheers!

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

That is why on the { accessTokenFactory: () => store.state.accessToken } you should pass a function that will refresh the token. So when the token expires, it will automatically check for new token from this method. So don't store the token in store.state.accessToken...

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda