Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

201
Views
¿Cómo esperar una solicitud HTTP antes de intentar volver a conectar en Socket.IO (con RxJS)?

Estoy usando el cliente Socket.IO y tengo el siguiente código:

 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 } }) ) })

Básicamente, cada vez que un usuario inicia sesión ( signedInObservable ), solicito un ticket de mi servidor ( getNotificationsWebsocketTicket() ) y solo entonces abro una conexión websocket.

Ahora quiero hacer lo mismo para cuando una conexión se ha cerrado por algún motivo (fuera de línea temporal) y Socket.IO ha intentado volver a conectar.

¿Cómo puedo asegurarme de que Socket.IO intente "reconectarse" solo después de que hice una solicitud a getNotificationsWebsocketTicket() ? para que pueda volver a conectarme con los datos de auth ?

algo como:

 io.beforeReconnect(() => { return getNotificationsWebsocketTicket() }).then(ticket => io(SERVER_URL, { auth: { ticket: ticket accessToken: getToken() }) )
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!