无法获取主机地址trqauthd无法启动!!!退出安装程序(在serverdb初始化期间)

时间:2018-08-05 12:10:34

标签: torque

我已经安装了扭力,但是在serverdb初始化期间通过执行扭力.setup脚本来安装了扭力。

public class AsyncSendTestData extends AsyncTask<String, String, String> {

    public static final int CONNECTION_TIMEOUT=10000;
    public static final int READ_TIMEOUT=15000;
    Context context;

    ProgressDialog pdLoading;
    public AsyncSendTestData(Context context) {
        this.context = context;
        this.pdLoading = new ProgressDialog(context);


    }

    HttpURLConnection conn;
    URL url = null;

    @Override
    protected void onPreExecute() {
        super.onPreExecute();

        //this method will be running on UI thread
        pdLoading.setMessage("\tLoading...");
        pdLoading.setCancelable(false);
        pdLoading.show();

    }
    @Override
    protected String doInBackground(String... params) {
        try {

            // Enter URL address where your php file resides
            //url = new URL("http://localhost/test/login.inc.php");
            url = new URL("https://ctestapp.000webhostapp.com/TSR.php");


        } catch (MalformedURLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            return "exception";
        }
        try {
            // Setup HttpURLConnection class to send and receive data from php and mysql
            conn = (HttpURLConnection)url.openConnection();
            conn.setReadTimeout(READ_TIMEOUT);
            conn.setConnectTimeout(CONNECTION_TIMEOUT);
            conn.setRequestMethod("POST");

            // setDoInput and setDoOutput method depict handling of both send and receive
            conn.setDoInput(true);
            conn.setDoOutput(true);

            // Append parameters to URL
            Uri.Builder builder = new Uri.Builder()
                    .appendQueryParameter("doit", params[0]);
                    //.appendQueryParameter("pass", params[1]);
            String query = builder.build().getEncodedQuery();

            // Open connection for sending data
            OutputStream os = conn.getOutputStream();
            BufferedWriter writer = new BufferedWriter(
                    new OutputStreamWriter(os, "UTF-8"));
            writer.write(query);
            writer.flush();
            writer.close();
            os.close();
            conn.connect();

        } catch (IOException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
            return "exception";
        } catch (Exception e) {
            e.printStackTrace();
        }

        try {

            int response_code = conn.getResponseCode();

            // Check if successful connection made
            if (response_code == HttpURLConnection.HTTP_OK) {

                // Read data sent from server
                InputStream input = conn.getInputStream();
                BufferedReader reader =
                        new BufferedReader(new InputStreamReader(input));
                StringBuilder result = new StringBuilder();
                String line;

                while ((line = reader.readLine()) != null) {
                    result.append(line);
                }

                // Pass data to onPostExecute method
                return(result.toString());

            }else{

                return("unsuccessful");
            }

        } catch (IOException e) {
            e.printStackTrace();
            return "exception";
        } finally {
            conn.disconnect();
        }


    }

    @Override
    protected void onPostExecute(String result) {

        //this method will be running on UI thread

        pdLoading.dismiss();

        if(result.equalsIgnoreCase("true"))
        {
                /* Here launching another activity when login successful. If you persist login state
                use sharedPreferences of Android. and logout button to clear sharedPreferences.
                 */
            Toast.makeText(context, "Done" + result, Toast.LENGTH_SHORT).show();


          /*
            Intent intent = new Intent(context,SuccessActivity.class);
            startActivity(intent);
            MainActivity.this.finish();
            */

        }else if (result.equalsIgnoreCase("false")){

            // If username and password does not match display a error message
            Toast.makeText(context, "Invalid email or password", Toast.LENGTH_LONG).show();

        } else if (result.equalsIgnoreCase("exception") || result.equalsIgnoreCase("unsuccessful")) {

            Toast.makeText(context, "OOPs! Something went wrong. Connection Problem.", Toast.LENGTH_LONG).show();

        }
    }



}

猫/ etc / hosts

<?php
   if(isset($_POST['doit']))
   {
   $reversed = $_POST['doit'];
   echo $reversed;
   }
?>

我该如何解决以上错误?


0 个答案:

没有答案