socket timeout exception - android SocketTimeoutException -
hello creating app in need send info server getting logcat
11-05 12:06:35.838: w/system.err(16635): java.net.sockettimeoutexception 11-05 12:06:35.888: w/system.err(16635): @ java.net.plainsocketimpl.read(plainsocketimpl.java:492) 11-05 12:06:35.888: w/system.err(16635): @ java.net.plainsocketimpl.access$000(plainsocketimpl.java:46) 11-05 12:06:35.898: w/system.err(16635): @ java.net.plainsocketimpl$plainsocketinputstream.read(plainsocketimpl.java:241) 11-05 12:06:35.898: w/system.err(16635): @ org.apache.http.impl.io.abstractsessioninputbuffer.fillbuffer(abstractsessioninputbuffer.java:103) 11-05 12:06:35.898: w/system.err(16635): @ org.apache.http.impl.io.abstractsessioninputbuffer.readline(abstractsessioninputbuffer.java:191) 11-05 12:06:35.898: w/system.err(16635): @ org.apache.http.impl.conn.defaultresponseparser.parsehead(defaultresponseparser.java:82) 11-05 12:06:35.898: w/system.err(16635): @ org.apache.http.impl.io.abstractmessageparser.parse(abstractmessageparser.java:174) 11-05 12:06:35.908: w/system.err(16635): @ org.apache.http.impl.abstracthttpclientconnection.receiveresponseheader(abstracthttpclientconnection.java:180) 11-05 12:06:35.908: w/system.err(16635): @ org.apache.http.impl.conn.defaultclientconnection.receiveresponseheader(defaultclientconnection.java:235) 11-05 12:06:35.908: w/system.err(16635): @ org.apache.http.impl.conn.abstractclientconnadapter.receiveresponseheader(abstractclientconnadapter.java:259) 11-05 12:06:35.908: w/system.err(16635): @ org.apache.http.protocol.httprequestexecutor.doreceiveresponse(httprequestexecutor.java:279) 11-05 12:06:35.908: w/system.err(16635): @ org.apache.http.protocol.httprequestexecutor.execute(httprequestexecutor.java:121) 11-05 12:06:35.918: w/system.err(16635): @ org.apache.http.impl.client.defaultrequestdirector.execute(defaultrequestdirector.java:428) 11-05 12:06:35.918: w/system.err(16635): @ org.apache.http.impl.client.abstracthttpclient.execute(abstracthttpclient.java:555) 11-05 12:06:35.918: w/system.err(16635): @ org.apache.http.impl.client.abstracthttpclient.execute(abstracthttpclient.java:653) 11-05 12:06:35.918: w/system.err(16635): @ org.apache.http.impl.client.abstracthttpclient.execute(abstracthttpclient.java:627) 11-05 12:06:35.918: w/system.err(16635): @ org.apache.http.impl.client.abstracthttpclient.execute(abstracthttpclient.java:616) 11-05 12:06:35.928: w/system.err(16635): @ com.addonwebsolution.yarg.internet.httprequest.postdata(httprequest.java:86) 11-05 12:06:35.928: w/system.err(16635): @ com.addonwebsolution.yarg.internet.ahttprequest$4.run(ahttprequest.java:204) 11-05 12:06:35.928: w/system.err(16635): @ java.lang.thread.run(thread.java:841
)
and class
import java.io.ioexception; import java.util.iterator; import java.util.list; import java.util.map; import org.apache.http.httpresponse; import org.apache.http.namevaluepair; import org.apache.http.client.responsehandler; import org.apache.http.client.entity.urlencodedformentity; import org.apache.http.client.methods.httpget; import org.apache.http.client.methods.httppost; import org.apache.http.impl.client.basicresponsehandler; import org.apache.http.impl.client.defaulthttpclient; import org.apache.http.params.basichttpparams; import org.apache.http.params.httpconnectionparams; import org.apache.http.params.httpparams; import org.apache.http.protocol.basichttpcontext; import org.apache.http.protocol.httpcontext; import org.apache.http.util.entityutils; import android.util.log; /** * class sends info through , post methods * * */ public class httprequest { defaulthttpclient httpclient; httpcontext localcontext; private string ret; httpresponse response = null; httppost httppost = null; httpget httpget = null; @suppresswarnings("rawtypes") map.entry me; @suppresswarnings("rawtypes") iterator i; public httprequest() { httpparams myparams = new basichttpparams(); httpconnectionparams.setconnectiontimeout(myparams, 50000); httpconnectionparams.setsotimeout(myparams, 50000); httpclient = new defaulthttpclient(myparams); localcontext = new basichttpcontext(); } public void clearcookies() { httpclient.getcookiestore().clear(); } public string sendget(string url) { httpget = new httpget(url); seek { response = httpclient.execute(httpget); } grab (exception e) { e.printstacktrace(); } seek { ret = entityutils.tostring(response.getentity()); } grab (ioexception e) { log.e("httprequest", "" + e.getmessage()); } grab (exception e) { e.printstacktrace(); } homecoming ret; } public string postdata(string url, list<namevaluepair> namevaluepairs) throws exception { system.out.println("in post data>>>>>>>>>>>>>>>>>"); // getting response handler handling post response responsehandler<string> res = new basicresponsehandler(); httppost postmethod = new httppost(url); // setting info sent postmethod.setentity(new urlencodedformentity(namevaluepairs)); // execute http post request string response = httpclient.execute(postmethod, res); homecoming response; } }
calling method like
11-05 12:06:35.838: w/system.err(16635): java.net.sockettimeoutexception 11-05 12:06:35.888: w/system.err(16635): @ java.net.plainsocketimpl.read(plainsocketimpl.java:492) 11-05 12:06:35.888: w/system.err(16635): @ java.net.plainsocketimpl.access$000(plainsocketimpl.java:46) 11-05 12:06:35.898: w/system.err(16635): @ java.net.plainsocketimpl$plainsocketinputstream.read(plainsocketimpl.java:241) 11-05 12:06:35.898: w/system.err(16635): @ org.apache.http.impl.io.abstractsessioninputbuffer.fillbuffer(abstractsessioninputbuffer.java:103) 11-05 12:06:35.898: w/system.err(16635): @ org.apache.http.impl.io.abstractsessioninputbuffer.readline(abstractsessioninputbuffer.java:191) 11-05 12:06:35.898: w/system.err(16635): @ org.apache.http.impl.conn.defaultresponseparser.parsehead(defaultresponseparser.java:82) 11-05 12:06:35.898: w/system.err(16635): @ org.apache.http.impl.io.abstractmessageparser.parse(abstractmessageparser.java:174) 11-05 12:06:35.908: w/system.err(16635): @ org.apache.http.impl.abstracthttpclientconnection.receiveresponseheader(abstracthttpclientconnection.java:180) 11-05 12:06:35.908: w/system.err(16635): @ org.apache.http.impl.conn.defaultclientconnection.receiveresponseheader(defaultclientconnection.java:235) 11-05 12:06:35.908: w/system.err(16635): @ org.apache.http.impl.conn.abstractclientconnadapter.receiveresponseheader(abstractclientconnadapter.java:259) 11-05 12:06:35.908: w/system.err(16635): @ org.apache.http.protocol.httprequestexecutor.doreceiveresponse(httprequestexecutor.java:279) 11-05 12:06:35.908: w/system.err(16635): @ org.apache.http.protocol.httprequestexecutor.execute(httprequestexecutor.java:121) 11-05 12:06:35.918: w/system.err(16635): @ org.apache.http.impl.client.defaultrequestdirector.execute(defaultrequestdirector.java:428) 11-05 12:06:35.918: w/system.err(16635): @ org.apache.http.impl.client.abstracthttpclient.execute(abstracthttpclient.java:555) 11-05 12:06:35.918: w/system.err(16635): @ org.apache.http.impl.client.abstracthttpclient.execute(abstracthttpclient.java:653) 11-05 12:06:35.918: w/system.err(16635): @ org.apache.http.impl.client.abstracthttpclient.execute(abstracthttpclient.java:627) 11-05 12:06:35.918: w/system.err(16635): @ org.apache.http.impl.client.abstracthttpclient.execute(abstracthttpclient.java:616) 11-05 12:06:35.928: w/system.err(16635): @ com.addonwebsolution.yarg.internet.httprequest.postdata(httprequest.java:86) 11-05 12:06:35.928: w/system.err(16635): @ com.addonwebsolution.yarg.internet.ahttprequest$4.run(ahttprequest.java:204) 11-05 12:06:35.928: w/system.err(16635): @ java.lang.thread.run(thread.java:841)
android socket-timeout-exception
No comments:
Post a Comment