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

205
Vistas
How to wait an HTTP request before atttempting to reconnect in Socket.IO (with RxJS)?

I'm using Socket.IO client and have the following code:

export const notificationsWsSubject = new BehaviorSubject<Socket | null>(null)

signedInObservable.pipe(
    switchMap(user => forkJoin([of(user), from(getNotificationsWebsocketTicket())]))
).subscribe(values => {
    notificationsWsSubject.next(
        io(SERVER_URL, {
            auth: {
                ticket: values[1].data,
                accessToken: values[0].accessToken
            }
        })
    )
})

basically whenever a user signs in (signedInObservable) I request a ticket from my server (getNotificationsWebsocketTicket()) and only then I actually open a websocket connection.

Now I want to do the same for when a connection has closed for some reason (temporary offline) and a reconnnect attempt has been made by Socket.IO.

How can I make sure Socket.IO attempts to "reconnect" only after I made a request to getNotificationsWebsocketTicket()? so that I can reconnect again with auth data?

something like:

io.beforeReconnect(() => {
  return getNotificationsWebsocketTicket()
}).then(ticket => io(SERVER_URL, { 
    auth: { 
        ticket: ticket
        accessToken: getToken()
    })
)
about 4 years ago · Juan Pablo Isaza
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