Reputation: 342
i have a controller method that return an excel file developed using dotnet core 2.2. The method work fine while testing on my local IIS. However the same method returns a 502 gateway error when deployed as a container on openshift. Can someone please help understand the issue here. Also please note that these requests are routed through an Ocelot gateway api.
[HttpGet, Route("GetCaseFeedData")]
public async Task<FileResult> GetCaseFeedData([FromQuery] int caseId, [FromQuery] int proposalId, [FromQuery] int equipmentId)
{
try
{
var queryParams = new Dictionary<string, string> { { "caseId", caseId.ToString() }, { "proposalId", proposalId.ToString() }, { "equipmentId", equipmentId.ToString() } };
var restObj = _restFactory.createRestRequest(Method.GET, "PsaDataFetch-api/GetCaseFeedCompositionForSimulation", queryParams);
Console.WriteLine(restObj.Item2.BaseUrl);
var response = await restObj.Item2.ExecuteTaskAsync(restObj.Item1);
if (response.StatusCode == HttpStatusCode.OK)
{
var outPut = JsonConvert.DeserializeObject<CaseFeedCompositionResponse>(response.Content);
Console.WriteLine("inside status ok");
Console.WriteLine(_hostingEnvironment.ContentRootPath, "App_data", "PSASim v5.1 template.xlsm");
var excelPackage = await _excelService.PopulatePsaSimFile(outPut, Path.Combine(_hostingEnvironment.ContentRootPath, "App_Data", "PSASim v5.1 template.xlsm"));
return File(_excelHelper.ConvertExcelToByteArray(excelPackage), ContentTypeEnums.excel, "template"+".xlsm");
}
else
{
Console.WriteLine("inside else portion");
return null;
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
throw ex;
}
}
UPDATE: I can see in the logs the below error message:
[08:08:52 INF] Executed action method STSLog.PsaSIM.API.Controllers.PSASimulatorController.GetCaseFeedData (UOP.TOOLS.STSLOG.PSASIM.API.Web), returned result Microsoft.AspNetCore.Mvc.FileContentResult in 95501.3656ms. [08:08:52 INF] Executing Microsoft.AspNetCore.Mvc.FileContentResult, sending file with download name 'template.xlsm' ... [08:08:52 INF] Connection id "0HLTJF7INHERP", Request id "0HLTJF7INHERP:00000001": the application aborted the connection.
Upvotes: 1
Views: 1115
Reputation: 342
I was finally able to overcome this issue, posting my solution here so that it helps someone else. Openshift uses ha proxy as its ingress pod, the time out was occurring since it waits for only 30 seconds for a request to complete. This setting can be overriden in the routes as below
Upvotes: 2