title: Why my android app isn't responding after POST method?
body: <p>I have a problem. I'm trying to execute POST method to my Node.js server. After POST method I'm getting all the data in server but then my app isn't responding a few seconds. Is there some bugs in my code?</p>
  
  <p>My POST method:</p>
  
  <pre><code>public static void setTemp(String address, String hot, String cold) throws IOException
      {
          URL url = new URL(address); //in the real code, there is an ip and a port
          HttpURLConnection conn = (HttpURLConnection) url.openConnection();
          conn.setRequestMethod("POST");
          conn.setRequestProperty("Content-Type", "application/json");
          try {
              conn.connect();
  
              JSONObject jsonParam = new JSONObject();
              jsonParam.put("hot", hot);
              jsonParam.put("cold", cold);
  
              DataOutputStream os = new DataOutputStream(conn.getOutputStream());
              os.writeBytes(jsonParam.toString());
  
              os.flush();
              os.close();
  
              Log.i("STATUS", String.valueOf(conn.getResponseCode()));
              Log.i("MSG" , conn.getResponseMessage());
  
          } catch (Exception e) {
  
          }
          finally {
              conn.disconnect();
          }
      }
  </code></pre>
  
  <p>This is how I call the POST method:</p>
  
  <pre><code>    private void setTemp(String hot, String cold)
      {
          try {
              WebAPI.setTemp(Tools.RestURLPost, hot, cold);
          }
          catch(IOException e) {
              e.printStackTrace();
          }
      }
  </code></pre>
  
  <p>And here you can find my Node.js method which I use to test successful parsing of JSON:</p>
  
  <pre><code>router.post('/post', function(req, res, next) {
    console.log(req.body);
  });
  </code></pre>