java - Why do i get a connect failed:ETIMEDOUT? -
i have written following asynctask in order fetch json data.i getting following exception.i tried run in emulator.
class fetchdata extends asynctask<string,void,string>{ @override protected string doinbackground(string[] values) { try { java.net.url url = new url("http://www.json-generator.com/api/json/get/ckxagapilc?indent=2"); httpurlconnection connection = (httpurlconnection) url.openconnection(); inputstream inputstream = connection.getinputstream(); inputstreamreader reader = new inputstreamreader(inputstream); bufferedreader bufferedreader = new bufferedreader(reader); stringbuilder stringbuilder = new stringbuilder(); string tempstring; while ((tempstring = bufferedreader.readline()) != null) { stringbuilder.append(tempstring); stringbuilder.append("\n"); } log.i("tag","string builder"+stringbuilder.tostring()); return stringbuilder.tostring(); } catch (ioexception e) { e.printstacktrace(); } return null; }
this exception getting
java.net.connectexception: failed connect www.json-generator.com/216.58.197.51 (port 80): connect failed: etimedout (connection timed out) 11-08 02:50:59.197 15857-26127/com.mindtree.a03_m6_assign_v21 w/system.err: @ libcore.io.iobridge.connect(iobridge.java:124) 11-08 02:50:59.197 15857-26127/com.mindtree.a03_m6_assign_v21 w/system.err: @ java.net.plainsocketimpl.connect(plainsocketimpl.java:183) 11-08 02:50:59.198 15857-26127/com.mindtree.a03_m6_assign_v21 w/system.err: @ java.net.plainsocketimpl.connect(plainsocketimpl.java:452) 11-08 02:50:59.200 15857-26127/com.mindtree.a03_m6_assign_v21 w/system.err: @ java.net.socket.connect(socket.java:884) 11-08 02:50:59.202 15857-26127/com.mindtree.a03_m6_assign_v21 w/system.err: @ com.android.okhttp.internal.platform.connectsocket(platform.java:117) 11-08 02:50:59.203 15857-26127/com.mindtree.a03_m6_assign_v21 w/system.err: @ com.android.okhttp.internal.http.socketconnector.connectrawsocket(socketconnector.java:160) 11-08 02:50:59.204 15857-26127/com.mindtree.a03_m6_assign_v21 w/system.err: @ com.android.okhttp.internal.http.socketconnector.connectcleartext(socketconnector.java:67) 11-08 02:50:59.204 15857-26127/com.mindtree.a03_m6_assign_v21 w/system.err: @ com.android.okhttp.connection.connect(connection.java:152) 11-08 02:50:59.204 15857-26127/com.mindtree.a03_m6_assign_v21 w/system.err: @ com.android.okhttp.connection.connectandsetowner(connection.java:185)
Comments
Post a Comment