title: HttpUrlConnection returns -1 status code
body: <p>I have problem with connecting to my server. Following code returns -1 as response code and null as response message.</p>
  
  <pre><code>  protected Boolean doInBackground(MyTaskParams... params) {
      URL url = null;
      String load = params[0].jobj.toString();
      try {
          url = new URL(params[0].serverUrl);
      } catch (MalformedURLException e) {
          e.printStackTrace();
      }
      try {
          HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
  
          urlConnection.setConnectTimeout(3000);
          urlConnection.setReadTimeout(3000);
          urlConnection.setRequestMethod("POST");
          urlConnection.setRequestProperty("Content-Type", "application/json; charset=UTF-8");
          urlConnection.setChunkedStreamingMode(0);
          urlConnection.setDoOutput(true);
          urlConnection.setDoInput(true);
          urlConnection.connect();
  
          OutputStreamWriter osw = new OutputStreamWriter(urlConnection.getOutputStream());
          osw.write(load);
          osw.flush();
          osw.close();
  
          if(urlConnection.getResponseCode()==200 &amp;&amp; urlConnection.getResponseMessage().contains("true") ) return true;
          else return false;
      } catch (IOException e) {
          e.printStackTrace();
      }
      return false;
  }
  </code></pre>
  
  <p>While debbuging url and body content (which is load in code) are correct. When I try to connect with the server using those params with Fiddler it works perfectly and I get 200 status code. Do you have any ideas what is wrong?</p>
  
  <p>Im passing jData object as the jobj:</p>
  
  <pre><code>        JSONObject User=new JSONObject();
          JSONObject Mobile=new JSONObject();
          JSONObject jData=new JSONObject();
          try {
              User.put ("UserLogin", "test");
              User.put ("UserPassword", "test");
              Mobile.put ("MobileIDD", IDD);
              Mobile.put("MobileToken", token);
              jData.put("Mobile", Mobile);
              jData.put("User", User);
          } catch (JSONException e) {
              e.printStackTrace();
          }
  </code></pre>
  
  <p>@EDIT
  Solution with <code>System.setProperty("http.keepAlive", "false")</code> didnt help.</p>