Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/37.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
连接错误node.js服务器。android中显示无法访问主机的Http请求_Android_Node.js_Mongodb_Web Services_Loopj - Fatal编程技术网

连接错误node.js服务器。android中显示无法访问主机的Http请求

连接错误node.js服务器。android中显示无法访问主机的Http请求,android,node.js,mongodb,web-services,loopj,Android,Node.js,Mongodb,Web Services,Loopj,我使用loopj库进行http请求,使用genymotion进行测试。我还想在我的移动设备上进行测试,但每当我点击按钮调用onclick函数时,它就会显示主机在每个ip上都无法访问 代码如下: public void onClick(View view) { username = emailET.getText().toString(); password = pwdET.getText().toString(); Asyn

我使用loopj库进行http请求,使用genymotion进行测试。我还想在我的移动设备上进行测试,但每当我点击按钮调用onclick函数时,它就会显示主机在每个ip上都无法访问

代码如下:

public void onClick(View view) {
            username = emailET.getText().toString();
            password = pwdET.getText().toString();
            AsyncHttpClient client = new AsyncHttpClient();
            RequestParams params = new RequestParams();
            params.put("username", username);
            params.put("password", password);
            client.post("http://10.0.3.2:3000/index", params, new TextHttpResponseHandler() {
                        @Override
                        public void onSuccess(int statusCode, Header[] headers, String res) {
                            try {
                                JSONObject obj = new JSONObject(res);
                                if(obj.getString("success").equals("true")){
                                    Toast.makeText(getApplicationContext(),"Service connected", Toast.LENGTH_LONG);
                                }
                            } catch (JSONException e) {
                                e.printStackTrace();
                                Toast.makeText(getApplicationContext(),"Server not connected",Toast.LENGTH_LONG);
                            }
                            // called when response HTTP status is "200 OK"
                        }

                        @Override
                        public void onFailure(int statusCode, Header[] headers, String res, Throwable t) {
                            // called when response HTTP status is "4XX" (eg. 401, 403, 404)
                            Toast.makeText(getApplicationContext(),"Bad Request",Toast.LENGTH_LONG);
                        }
                    }
            );
下面是node.js和mongodb服务器运行的代码片段:


图像作为链接上载图像作为链接上载