Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/214.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android HttpRequest超时_Android_Http_Get_Server - Fatal编程技术网

Android HttpRequest超时

Android HttpRequest超时,android,http,get,server,Android,Http,Get,Server,我正在尝试使用以下格式从我的应用程序向我的计算机发出get请求 myu-ip:8888/msg/myu-message 当我打开连接时,它会工作,但执行永远不会超过执行(请求)部分。它在执行get请求之前超时(1分钟到)。请求url是正确的,因为我已直接在pc浏览器上尝试。 我的android清单拥有互联网权限。 这是密码 private static JSONObject sendPetition(HttpUriRequest request) throws Exception{

我正在尝试使用以下格式从我的应用程序向我的计算机发出get请求
myu-ip:8888/msg/myu-message
当我打开连接时,它会工作,但执行永远不会超过执行(请求)部分。它在执行get请求之前超时(1分钟到)。请求url是正确的,因为我已直接在pc浏览器上尝试。 我的android清单拥有互联网权限。 这是密码

    private static JSONObject sendPetition(HttpUriRequest request) throws Exception{
        AndroidHttpClient client;

        HttpResponse response;
        JSONObject responseJSON;

        client = AndroidHttpClient.newInstance("IPM-HttpClient/UNAVAILABLE");
        response=  client.execute(request);
        responseJSON = new JSONObject(EntityUtils.toString(response.getEntity()));
        client.close();
        return responseJSON;
    }
编辑1:

好像我没有提供足够的信息。对不起:这是日志

11-29 12:10:21.503 5546-5546/com.example.alvarofeal.aplicacioncliente I/View﹕ 修改发送到android.widget.Button{41f3ede0 VFED..C..P..311754-407826#7f080002应用程序:id/Button},event=MotionEvent{action=action\u up,id[0]=0,x[0]=59.31427,y[0]=32.06659,工具类型[0]=TOOL_TYPE_FINGER,buttonState=0,metaState=0,flags=0x0,edgeFlags=0x0,pointerCount=1,historySize=0,eventTime=2125112,downless=2124997,deviceId=4,source=0x1002}

11-29 12:10:21.504 5546-5546/com.example.alvarofeal.aplicacioncliente V/Provider/Settings﹕ 从设置缓存中,名称=声音效果,值=0

11-29 12:10:21.506 5546-5546/com.example.alvarofeal.aplicacioncliente D/dalvikvm﹕ 创建interp线程:堆栈大小=128KB

11-29 12:10:21.506 5546-5546/com.example.alvarofeal.aplicacioncliente D/dalvikvm﹕ 创建新线程

11-29 12:10:21.5075546-5546/com.example.alvarofeal.aplicacioncliente D/dalvikvm﹕ 创建新线程

11-29 12:10:21.5075546-5546/com.example.alvarofeal.aplicacioncliente D/dalvikvm﹕ 更新线程列表

11-29 12:10:21.5075546-5669/com.example.alvarofeal.aplicacioncliente D/dalvikvm﹕ threadid=12:0x6126a000处的内部堆栈

11-29 12:10:21.5075546-5669/com.example.alvarofeal.aplicacioncliente D/dalvikvm﹕ threadid=12:从interp创建

11-29 12:10:21.5075546-5546/com.example.alvarofeal.aplicacioncliente D/dalvikvm﹕ 启动新线程

11-29 12:10:21.5075546-5669/com.example.alvarofeal.aplicacioncliente D/dalvikvm﹕ threadid=12:通知调试器

11-29 12:10:21.5075546-5669/com.example.alvarofeal.aplicacioncliente D/dalvikvm﹕ threadid=12(AsyncTask#1):调用run()

11-29 12:10:21.509 5546-5669/com.example.alvarofeal.aplicacioncliente I/System.out﹕ httpget:http://192.168.0.8:8888/msg/play/eABHFSQKCdU

11-29 12:10:21.512 5546-5669/com.example.alvarofeal.aplicacioncliente I/System.out﹕ http://192.168.0.8:8888/msg/play/eABHFSQKCdU

11-29 12:10:21.519 5546-5669/com.example.alvarofeal.aplicacioncliente D/dalvikvm﹕ 创建interp线程:堆栈大小=128KB

11-29 12:10:21.519 5546-5669/com.example.alvarofeal.aplicacioncliente D/dalvikvm﹕ 创建新线程

11-29 12:10:21.519 5546-5669/com.example.alvarofeal.aplicacioncliente D/dalvikvm﹕ 创建新线程

11-29 12:10:21.519 5546-5669/com.example.alvarofeal.aplicacioncliente D/dalvikvm﹕ 更新线程列表

11-29 12:10:21.519 5546-5670/com.example.alvarofeal.aplicacioncliente D/dalvikvm﹕ threadid=13:0x6138a000处的内部堆栈

11-29 12:10:21.519 5546-5670/com.example.alvarofeal.aplicacioncliente D/dalvikvm﹕ threadid=13:从interp创建

11-29 12:10:21.519 5546-5669/com.example.alvarofeal.aplicacioncliente D/dalvikvm﹕ 启动新线程

11-29 12:10:21.520 5546-5670/com.example.alvarofeal.aplicacioncliente D/dalvikvm﹕ threadid=13:通知调试器

11-29 12:10:21.520 5546-5670/com.example.alvarofeal.aplicacioncliente D/dalvikvm﹕ threadid=13(RefQueueWorker@org.apache.http.impl.conn.tsccm.ConnPoolByRoute@41fae950):调用run()

11-29 12:10:21.533 5546-5669/com.example.alvarofeal.aplicacioncliente I/System.out﹕ [插座][0]连接/192.168.0.8:8888;LocalPort=34838(60000)

11-29 12:10:21.533 5546-5669/com.example.alvarofeal.aplicacioncliente I/System.out﹕ [CDS]连接[/192.168.0.8:8888]tm:60

11-29 12:10:21.534 5546-5669/com.example.alvarofeal.aplicacioncliente D/Posix﹕ [Posix_connect Debug]Process com.example.alvarofeal.aplicacionclient:8888

之后,它只抛出connectiontimeout异常:

编辑3:

11-29 12:27:19.988 6207-6277/com.example.alvarofeal.aplicacionclient W/System.err﹕ org.apache.http.conn.ConnectTimeoutException:连接到/192.168.0.8:8888超时

11-29 12:27:19.990 6207-6277/com.example.alvarofeal.aplicacionclient W/System.err﹕ 位于org.apache.http.conn.scheme.PlainSocketFactory.connectSocket(PlainSocketFactory.java:121)

11-29 12:27:19.991 6207-6277/com.example.alvarofeal.aplicacionclient W/System.err﹕ 位于org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:144)

11-29 12:27:19.992 6207-6277/com.example.alvarofeal.aplicacionclient W/System.err﹕ 位于org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:164)

11-29 12:27:19.992 6207-6277/com.example.alvarofeal.aplicacionclient W/System.err﹕ 位于org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:119)

11-29 12:27:19.993 6207-6277/com.example.alvarofeal.aplicacionclient W/System.err﹕ 位于org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:365)

11-29 12:27:19.994 6207-6277/com.example.alvarofeal.aplicacionclient W/System.err﹕ 位于org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:587)

11-29 12:27:19.995 6207-6277/com.example.alvarofeal.aplicacionclient W/System.err﹕ 位于org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:511)

11-29 12:27:19.996 6207-6277/com.example.alvarofeal.aplicacionclient W/System.err﹕ 位于org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:489)

11-29 12:27:19.996 6207-6277/com.example.alvarofeal.aplic
   private static JSONObject sendPetition(HttpUriRequest request) throws Exception{
        AndroidHttpClient client;
        int timeout = 5000

        HttpResponse response;
        JSONObject responseJSON;

        client = AndroidHttpClient.newInstance("IPM-HttpClient/UNAVAILABLE");

        HttpParams httpParams = new BasicHttpParams();
        HttpConnectionParams.setConnectionTimeout(httpParams, timeout);
        HttpConnectionParams.setSoTimeout(httpParams, timeout);

        request.setParams(httpParams);

        response = client.execute(request);
        responseJSON = new JSONObject(EntityUtils.toString(response.getEntity()));
        client.close();
        return responseJSON;
    }