마스터Q&A 안드로이드는 안드로이드 개발자들의 질문과 답변을 위한 지식 커뮤니티 사이트입니다. 안드로이드펍에서 운영하고 있습니다. [사용법, 운영진]

Android Connection timed out 에러가 뜨네요 도와주세요 ㅠㅠ

0 추천

android <-> php <-> mysql 연동을 하려고 하고 있습니다.  php내에서  mysql로 데이터가 넘어가는거는 확인이 되었는데  android에서  php로 데이터가 넘어가지 않고 있습니다. 

밑에는 코드부분입니다.. ㄸㅏ로 오류메시지가 뜨는거는 없었습니다.  도와주세요 

 

class Signup extends  AsyncTask<String,Void,String>{
    ProgressDialog progressDialog;

    @Override
    protected void onPreExecute() {
        super.onPreExecute();
        progressDialog = ProgressDialog.show(Sign.this,
                "Please Wait", "회원가입중입니다.", true, true);
    }

    @Override
    protected void onPostExecute(String result) {
        super.onPostExecute(result);
        progressDialog.dismiss();
        mTextViewResult.setText(result);
        Toast toast = Toast.makeText(getApplicationContext(),"회원가입을 완료하셨습니다.",Toast.LENGTH_SHORT);
        toast.show();
    }


    @Override
    protected String doInBackground(String... params) {
        String email = (String)params[0];
        String pass = (String)params[1];
        String name = (String)params[2];
        String age = (String)params[3];
        String sex = (String)params[4];

        String serverURL = "http://210.119.146.209/PHP_signup.php";
        String postParameters = "email=" + email + "&pass=" + pass + "&name=" +
                name + "&age=" + age+ "&sex" + sex;

        try{
            URL url = new URL(serverURL);
            HttpURLConnection httpURLConnection = (HttpURLConnection)url.openConnection();
            //httpURLConnection.setReadTimeout(5000);
            //httpURLConnection.setConnectTimeout(5000);
            httpURLConnection.setRequestMethod("POST");
            httpURLConnection.connect();;

            OutputStream outputStream = httpURLConnection.getOutputStream();
            outputStream.write(postParameters.getBytes("UTF-8"));
            outputStream.flush(); //현재 버퍼에 저장되어 있는 내용을 클라이언트로 전송하고 버퍼를 비운다.
            outputStream.close();

            int responseStatusCode = httpURLConnection.getResponseCode();

            InputStream inputStream;
            if(responseStatusCode == HttpURLConnection.HTTP_OK) {
                inputStream = httpURLConnection.getInputStream();
            }
            else{
                inputStream = httpURLConnection.getErrorStream();
            }

            InputStreamReader inputStreamReader = new InputStreamReader(inputStream, "UTF-8");
            BufferedReader bufferedReader = new BufferedReader(inputStreamReader);

            StringBuilder sb = new StringBuilder();
            String line = null;

            while((line = bufferedReader.readLine()) != null){
                sb.append(line);
            }
            bufferedReader.close();
            return sb.toString();

        }catch (Exception e){
            return new String("Error:"+e.getMessage());
        }

    }
}
초까봄 (160 포인트) 님이 2018년 5월 13일 질문

1개의 답변

0 추천
방화벽에 포트 열어 놨는지 확인좀요
익명사용자 님이 2018년 5월 14일 답변
열었어요 ㅠㅠㅠㅠㅠ  무슨 문제일까여??? port 80 열었어요  XAMPP Contorol Panel  쓰고 있는데  안되네요 ㅠㅠ
...