2016-05-25 08:58:34
Yesterday, the white system because the call external HTTP interface, timeout does not release, resulting in a slow page response, a long time, reported 502 error.
On the Internet to check the next, 502 error is because the service for the customer's request did not get a timely response, query log, found a lot of HTTP interface exception, the page response is also very slow.
Instantly think of shortening the HTTP client call HTTP interface Timeout time, search this blog http://blog.csdn.net/xinying0424/article/details/36006383 thanks
HttpClient 4: Connection timeout: Connection timeout httpclient.getparams (). Setparameter (coreconnectionpnames.connection_timeout,60000);// or Httpconnectionparams.setconnectiontimeout (params,6000); Read timeout: Httpclient.getparams (). Setparameter ( coreconnectionpnames.so_timeout,60000);//or Httpconnectionparams.setsotimeout (params,60000); HttpClient 3: Connection timeout: Httpclient.gethttpconnectionmanager (). Getparams (). Setconnectiontimeout (60000); Read timeout: Httpclient.gethttpconnectionmanager (). Getparams (). Setsotimeout (60000);
Found that I wrote this in the code, but the time is too long to configure
private static Multithreadedhttpconnectionmanager ConnectionManager = null; private static int connectiontimeout = 2000;t private static int sockettimeout = 10000; private static int maxconnectionperhost =; private static int maxtotalconnections =; private static HttpClient client; static { ConnectionManager = new Multithreadedhttpconnectionmanager (); Connectionmanager.getparams (). Setconnectiontimeout (connectiontimeout); Connectionmanager.getparams (). Setsotimeout (sockettimeout); Connectionmanager.getparams (). Setdefaultmaxconnectionsperhost (maxconnectionperhost); Connectionmanager.getparams (). Setmaxtotalconnections (maxtotalconnections); Client = new HttpClient (ConnectionManager); }
Then I adjusted the Sockettimeout to 2000, the local want to test, the result ...
Java.lang.IllegalArgumentException:host parameter is null call interface error
Checked the next http://wang371134086.iteye.com/blog/1688458 unexpectedly call HTTP interface did not write HTTP.//, plus this paragraph resolution
Problem solving record, thanks for the blog.
http://blog.csdn.net/xinying0424/article/details/36006383
http://wang371134086.iteye.com/blog/1688458
Http://blog.sina.com.cn/s/blog_a577563c01013tlz.html
http://jinnianshilongnian.iteye.com/blog/2089792
http://www.zhihu.com/question/21647204
An on-line HTTP interface call does not pass the related resolution procedure