I have a windows service .Net client comunicating with a PHP web service. The basic idea, the .Net client send information to php to write in data base, this process take araund 1min, the problem is that, when it takes more, the HttpResponseMessage comes with BadGateway, the funny thing is php actually write all that has to write in the database even when it takes more than 1min. I try to set the TimeOut of HttpClient to 10min:
//code for the stuff making
Logger.WriteLog("Sending Stuff");
using (var client = new HttpClient())
{
client.Timeout = new TimeSpan(0,10,0);
httpResponseMessage = client.PostAsync(url, content).Result;
Logger.WriteLog(httpResponseMessage.StatusCode.ToString());
Logger.WriteLog(httpResponseMessage.ToString());
}
But still, it fail with more than 1min response, the php web service it suppose to have a timeout of 10min too. I log the full response and i got the bad Gateway:
2016-04-25 11:12:24,045 INFO - *Sending Stuff
2016-04-25 11:13:23,413 INFO - OK
2016-04-25 11:13:23,414 INFO - StatusCode: 200, ReasonPhrase: 'OK', Version: 1.1, Content: System.Net.Http.StreamContent, Headers:
{
Pragma: no-cache
Connection: close
Cache-Control: no-store, must-revalidate, no-cache, post-check=0, pre-check=0
Date: Mon, 25 Apr 2016 14:12:37 GMT
Set-Cookie: PHPSESSID=lbhsue3pstc8smqihkoe0nouj1; path=/
Server: Apache/2.2.15
Server: (CentOS)
X-Powered-By: PHP/5.6.19
Content-Length: 52
Content-Type: application/json; charset=UTF8
Expires: Thu, 19 Nov 1981 08:52:00 GMT
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
2016-04-25 11:14:42,931 INFO - *Sending Stuff
2016-04-25 11:15:44,273 INFO - BadGateway
2016-04-25 11:15:44,274 INFO - StatusCode: 502, ReasonPhrase: 'Proxy Error', Version: 1.1, Content: System.Net.Http.StreamContent, Headers:
{
Connection: close
Date: Mon, 25 Apr 2016 14:14:43 GMT
Content-Length: 499
Content-Type: text/html; charset=iso-8859-1
}
//------------------------------------------------------------------------------------------------------------------------------------------------
2016-04-25 11:25:28,471 INFO - *Sending Stuff
2016-04-25 11:26:27,495 INFO - OK
2016-04-25 11:26:27,497 INFO - StatusCode: 200, ReasonPhrase: 'OK', Version: 1.1, Content: System.Net.Http.StreamContent, Headers:
{
Pragma: no-cache
Connection: close
Cache-Control: no-store, must-revalidate, no-cache, post-check=0, pre-check=0
Date: Mon, 25 Apr 2016 14:25:41 GMT
Set-Cookie: PHPSESSID=ja6f30mqlnhtdl8p44hddr43c3; path=/
Server: Apache/2.2.15
Server: (CentOS)
X-Powered-By: PHP/5.6.19
Content-Length: 52
Content-Type: application/json; charset=UTF8
Expires: Thu, 19 Nov 1981 08:52:00 GMT
}
My hope was that, timeout where the reason of the badgateway but it make not difference. Can someone tell me what are the possibilities of the badgateway, even when the process in php finish the task. Thanks in advance! PD:Sorry for my english