Anandhu Ajayakumar
Anandhu Ajayakumar

Reputation: 136

http request thorows ERR_EMPTY_RESPONSE after 4 minutes

I have an angular 5 node app. I am sending a request to node server and wait for the reply. Sometimes the response is sent from the server after 5-6 minutes. But after 4 minutes of waiting for the response, the http method throws an ERR_EMPTY_RESPONSE error.

I tried to use timeout() with the method. But it still throws error after 4 minutes.

Is there any way to make the http method wait longer or to avoid this error?

const body = JSON.stringify(params);
const headers = new HttpHeaders({'Content-Type': 'application/json'});
return this.http.post('/api/execute', body, {headers: headers})
  .map((response) => response)
  .catch((error) => Observable.throw(error));

Upvotes: 3

Views: 5108

Answers (2)

David
David

Reputation: 34435

Try setting Keep-Alive header

const headers = new HttpHeaders({'Content-Type': 'application/json', 'Keep-Alive': 'timeout=560'});

Upvotes: 1

Chris
Chris

Reputation: 58

Browsers have built in time outs, see this thread here Browser Timeouts

So, no, you cannot tell your JavaScript code to wait longer.

Upvotes: 0

Related Questions