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

202
Views
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
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!