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

310
Visualizações
eventSource fetch API reconnecting

I have used eventSourcePolyfill fetch API for server sent events. My problem is inspite of closing the connection from front end, it is getting called repeatedly with error message -

eventsource.js:913 Error: No activity within 45000 milliseconds. No response received. Reconnecting.

Please find the code below -

callSSE(that, uid) {
let authHeader = localStorage.getItem('token');
let obj = {
  Authorization: authHeader,
  progress_bar_guid: uid,
  heartbeatTimeout: 600*1000
}
this.source = new EventSourcePolyfill("SSE URL", {headers: obj});

this.source.addEventListener('message', function(e: any) {
  let dt = JSON.parse(e.data);
}, false)

this.source.addEventListener('open', function(e: any) {
  if (!e) {
    if (this.source) this.source.Close();
  }
  console.log('connected!');
}, false)
this.source.addEventListener('error', function(e: any) {
  if (this.source) {
    this.source.close();
  }
}, false)
this.source.addEventListener("COMPLETE", function(e: any) {
  let dt = JSON.parse(e.data);
  
  if (this.source) {
    this.source.Close(); //It is not coming here. Because this.source is undefined
  }
})
}

Server is sending the last record with data: COMPLETE. In the COMPLETE eventListener I want to close this.source connection. But somehow it is not closing.

Any help is appreciated!

Thanks,

error on console repeat progress call

about 4 years ago · Juan Pablo Isaza
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