title: HttpURLConnection .getInputStream() stop working
body: <p>I'm creating an Android project where the ActivityMain connects to a PHP file (in a local server, localhost) using HttpURLConnection;</p>
  
  <p>I have a problem with the following code line:</p>
  
  <pre><code>bufferedReader = new BufferedReader(new InputStreamReader((conn.getErrorStream())));
  </code></pre>
  
  <p>When I run the project, the application stops at this point, without return any error.</p>
  
  <p>Where is the problem?</p>
  
  <p>I report the code part here:</p>
  
  <pre><code>public class SendToLogin extends AsyncTask&lt;String, Object, String&gt; {
  
  //private EditText usernameField,passwordField;
  private String username, password;
  private Context context;
  private Boolean loggato = false;
  JSONObject rspJ;
  
  
  public SendToLogin(String usr, String psw, Context c) {
      username = usr;
      password = psw;
      context = c;
  }
  
  @Override
  protected void onPreExecute() {
  
  }
  
  @Override
  protected String doInBackground(String... params) {
      String link = params[0] + "?username=" + username.toString() + "&amp;password=" + password.toString();
      URL url = null;
      HttpURLConnection conn = null;
      BufferedReader bufferedReader = null;
      String result = "";
      String line = "";
      try {
  
          url = new URL(link);
          conn = (HttpURLConnection) url.openConnection();
          conn.setRequestMethod("GET");
          conn.setReadTimeout(1000);
          conn.setDoInput(true);
          int status = conn.getResponseCode();
  
  
          bufferedReader = new BufferedReader(new InputStreamReader((conn.getErrorStream())));
  
          while ((line = bufferedReader.readLine()) != null) {
              result += line + "\n";
          }
          bufferedReader.close();
          return result;
      } catch (MalformedURLException e) {
          e.printStackTrace();
      } catch (ProtocolException e) {
          e.printStackTrace();
      } catch (IOException e) {
          e.printStackTrace();
      }
      return null;
  }
  
  @Override
  protected void onPostExecute(String s) {
      //super.onPostExecute(aVoid);
      String result = s;
      JSONObject reader = null;
      try {
          reader = new JSONObject(result);
          String query_result = reader.getString("msg");
          if(query_result.toString() == "ok")
              new ListaUtenti();
          else {
              Toast loginErrorToast = Toast.makeText(context, "Errore! login errato!", Toast.LENGTH_SHORT);
          }
      } catch (JSONException e) {
          e.printStackTrace();
      }
      //new ReceiveToLogin().execute();
  
  }
  </code></pre>
  
  <p>}</p>
  
  <p>(The php code return a JSON line correct, when i use a browser to test it)</p>
  
  <p>Thanks you.</p>