我在Angular 4中提出了一個需求非常長的請求。 後端位於連接到Oracle數據庫的.Net Core 2.0中。它應該等待長時間的查詢才能在數據庫中運行以獲取數據並將其發送到客戶端。然而,似乎客戶端是無法等待的過程(所有記錄返回)結束時,我得到的是錯誤:如何處理Angular 4中的長時間請求?
Failed to load resource: the server responded with a status of 502 (Bad Gateway)
This error occurs when a CGI application does not return a valid set of HTTP headers, or when a proxy or gateway was unable to send the request to a parent gateway. You may need to get a network trace or contact the proxy server administrator, if it is not a CGI problem.
這不是一個超時錯誤,因爲我以爲這是的。 這裏是我的請求的代碼:
exportExcel(dadosConsulta: DadosConsultaModel) : Promise<any>{
let url ="/api/Relatorios/exportToExcel";
return this.http
.post(url, JSON.stringify(dadosConsulta),{ headers: this.headers })
.timeout(500000)
.toPromise()
.then(data => data.json())
.catch(this.handleError);
}
我怎樣才能防止這種情況發生?