android - HttpClient execute keeps giving ConnectTimeoutException -
android - HttpClient execute keeps giving ConnectTimeoutException -
i have big bug in application can't seem solve. whenever create rest phone call via next code:
httpget request = new httpget(url + getparams()); httpparams httpparameters = new basichttpparams(); httpconnectionparams.setconnectiontimeout(httpparameters, 5000); httpconnectionparams.setsotimeout(httpparameters, 10000); defaulthttpclient httpclient = new defaulthttpclient(httpparameters); httpclient.execute(request);
i error in ddms:
07-15 11:22:47.448: warn/system.err(973): org.apache.http.conn.connecttimeoutexception: connect (some ip-address) timed out
but code works perfect , receive info should. tested rest server phone call via normal webbrowser on computer , gives info within 100ms. doing wrong? tested on device, gives me same problem. glad if solve problem :)
the problem defaulthttpclient
. using asynchronously? since defaulthttpclient
not thread-safe, using in asynchronous environment might cause problem. i've had problem before when activity started multiple http connection @ same time , ended changing utilize httpurlconnection
. can refer site: http://www.vogella.de/articles/androidnetworking/article.html
android rest httpclient http-get connection-timeout
Comments
Post a Comment