我试图连接(http连接)到xampp数据库,但我得到了错误 和我运行应用程序的设备有相同的笔记本电脑wifi,我尝试添加:80后IP但没有任何变化 并且网址实际上有效url work well in browser
我的logcat是
E/dfdgfffffffffffff: http://127.0.0.1/Lotus/getscats.php?category=Atm
E/FSDGH: http://127.0.0.1/Lotus/getscats.php?category=Atm
V/PhoneWindow: DecorView setVisiblity: visibility = 0 ,Parent =ViewRoot{425e8978 com.example.karem.lotus/com.example.karem.lotus.Category_Activity,ident = 2}, this =com.android.internal.policy.impl.PhoneWindow$DecorView{425c8048 V.E..... R.....ID 0,0-0,0}
D/ActivityThread: ACT-LAUNCH_ACTIVITY handled : 0 / ActivityRecord{425c5790 token=android.os.BinderProxy@425c4ef8 {com.example.karem.lotus/com.example.karem.lotus.Category_Activity}}
D/GraphicBuffer: create handle(0x641daf68) (w:720, h:1184, f:1)
I/MaliEGL: [Mali]window_type=1, is_framebuffer=0, errnum = 0
I/MaliEGL: [Mali]surface->num_buffers=4, surface->num_frames=3, win_min_undequeued=1
[Mali]max_allowed_dequeued_buffers=3
D/GraphicBuffer: close handle(0x641daf68) (w:720 h:1184 f:1)
D/GraphicBuffer: create handle(0x641daf68) (w:720, h:1184, f:1)
D/OpenGLRenderer: setViewport 720x1184 <0x63bceca8>
E/RecyclerView: No adapter attached; skipping layout
V/InputMethodManager: onWindowFocus: android.support.v7.widget.RecyclerView{425da188 VFED.... .F....ID 0,0-720,1022 #7f070023 app:id/category_recycler_view} softInputMode=272 first=true flags=#1810100
START INPUT: android.support.v7.widget.RecyclerView{425da188 VFED.... .F....ID 0,0-720,1022 #7f070023 app:id/category_recycler_view} ic=null tba=android.view.inputmethod.EditorInfo@43342cc8 controlFlags=#105
E/RecyclerView: No adapter attached; skipping layout
D/OpenGLRenderer: prepareDirty (0.00, 0.00, 720.00, 1184.00) opaque 1 <0x63bceca8>
finish <0x63bceca8>
D/OpenGLRenderer: Flushing caches (mode 0)
D/GraphicBuffer: close handle(0x615712e0) (w:720 h:1184 f:1)
D/GraphicBuffer: close handle(0x62ff56b8) (w:720 h:1184 f:1)
D/GraphicBuffer: close handle(0x61583ee8) (w:720 h:1184 f:1)
close handle(0x6159f118) (w:720 h:1184 f:1)
I/System.out: No proyx setting for 127.0.0.1
D/dalvikvm: create interp thread : stack size=128KB
create new thread
new thread created
update thread list
D/dalvikvm: threadid=13: interp stack at 0x617a7000
threadid=13: created from interp
D/dalvikvm: start new thread
I/System.out: [socket][0] connection /127.0.0.1:80;LocalPort=52806(15000)
[CDS]connect[/127.0.0.1:80] tm:15
D/Posix: [Posix_connect Debug]Process com.example.karem.lotus :80
I/System.out: [socket][1:52806] exception
[CDS]close[52806]
D/dalvikvm: threadid=13: notify debugger
threadid=13 (OkHttp ConnectionPool): calling run()
E/fghjgjgf: Problem retrieving the earthquake JSON results.
java.net.ConnectException: failed to connect to /127.0.0.1 (port 80) after 15000ms: isConnected failed: ECONNREFUSED (Connection refused)
at libcore.io.IoBridge.isConnected(IoBridge.java:249)
at libcore.io.IoBridge.connectErrno(IoBridge.java:178)
at libcore.io.IoBridge.connect(IoBridge.java:112)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:192)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:475)
at java.net.Socket.connect(Socket.java:861)
at com.android.okhttp.internal.Platform.connectSocket(Platform.java:152)
at com.android.okhttp.Connection.connect(Connection.java:101)
at com.android.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:294)
at com.android.okhttp.internal.http.HttpEngine.sendSocketRequest(HttpEngine.java:255)
at com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:206)
at com.android.okhttp.internal.http.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:345)
at com.android.okhttp.internal.http.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:89)
at com.example.karem.lotus.CategoryAsyncTaskUtils.makeHttpRequest(CategoryAsyncTaskUtils.java:58)
at com.example.karem.lotus.CategoryAsycTask.doInBackground(CategoryAsycTask.java:20)
at com.example.karem.lotus.CategoryAsycTask.doInBackground(CategoryAsycTask.java:11)
at android.os.AsyncTask$2.call(AsyncTask.java:288)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:841)
Caused by: libcore.io.ErrnoException: isConnected failed: ECONNREFUSED (Connection refused)
at libcore.io.IoBridge.isConnected(IoBridge.java:234)
at libcore.io.IoBridge.connectErrno(IoBridge.java:178)
at libcore.io.IoBridge.connect(IoBridge.java:112)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:192)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:475)
at java.net.Socket.connect(Socket.java:861)
at com.android.okhttp.internal.Platform.connectSocket(Platform.java:152)
at com.android.okhttp.Connection.connect(Connection.java:101)
at com.android.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:294)
at com.android.okhttp.internal.http.HttpEngine.sendSocketRequest(HttpEngine.java:255)
at com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:206)
at com.android.okhttp.internal.http.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:345)
at com.android.okhttp.internal.http.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:89)
at com.example.karem.lotus.CategoryAsyncTaskUtils.makeHttpRequest(CategoryAsyncTaskUtils.java:58)
at com.example.karem.lotus.CategoryAsycTask.doInBackground(CategoryAsycTask.java:20)
at com.example.karem.lotus.CategoryAsycTask.doInBackground(CategoryAsycTask.java:11)
at android.os.AsyncTask$2.call(AsyncTask.java:288)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:841)
I/System.out: close [socket][/0.0.0.0:52806]
V/PhoneWindow: DecorView setVisiblity: visibility = 4 ,Parent =ViewRoot{42300778
com.example.karem.lotus/com.example.karem.lotus.MainActivity,ident = 1}, this =com.android.internal.policy.impl.PhoneWindow$DecorView{422c8568 I.E..... R....... 0,0-720,1184}
D/ActivityThread: ACT-STOP_ACTIVITY_HIDE handled : 0 / android.os.BinderProxy@422c5970
D/dalvikvm: threadid=13: exiting
threadid=13: bye!
我的http连接代码是
public static String makeHttpRequest(URL url) throws IOException {
String jsonResponse = "";
Log.e("FSDGH", url.toString());
// If the URL is null, then return early.
if (url == null) {
return jsonResponse;
}
HttpURLConnection urlConnection = null;
InputStream inputStream = null;
try {
urlConnection = (HttpURLConnection) url.openConnection();
urlConnection.setReadTimeout(10000 /* milliseconds */);
urlConnection.setConnectTimeout(15000 /* milliseconds */);
urlConnection.setRequestMethod("GET");
urlConnection.connect();
// If the request was successful (response code 200),
// then read the input stream and parse the response.
if (urlConnection.getResponseCode() == 200) {
inputStream = urlConnection.getInputStream();
jsonResponse = readFromStream(inputStream);
} else {
Log.e("vcvjgffghjj", "Error response code: " + urlConnection.getResponseCode());
}
} catch (IOException e) {
Log.e("fghjgjgf", "Problem retrieving the earthquake JSON results.", e);
} finally {
if (urlConnection != null) {
urlConnection.disconnect();
}
if (inputStream != null) {
inputStream.close();
}
}
return jsonResponse;
}
我搜索这个问题,但无法找到适合我的答案