title: ResourceAccessException: I/O error on POST request
body: <p>I have an error when trying to post data to an api. Below is the code snippet. Looking forward for some help soon!Thanks</p>
  
  <pre class="lang-java prettyprint-override"><code>String id= Comment.getId();
  String authStr = "userName:password";
  String base64Creds = Base64.getEncoder().encodeToString(authStr.getBytes());
  // create headers
  HttpHeaders headers = new HttpHeaders();
  headers.add("Authorization", "Basic " + base64Creds);
  headers.setContentType(MediaType.APPLICATION_JSON);
  JSONObject commonJsonObject = new JSONObject();
  commonJsonObject .put("body","password");
  SimpleClientHttpRequestFactory clientHttpRequestFactory = new SimpleClientHttpRequestFactory();
  // Connect timeout: time is in milliseconds
  clientHttpRequestFactory.setConnectTimeout(3000);
  // Read timeout: time is in milliseconds
  clientHttpRequestFactory.setReadTimeout(3000);
  HttpEntity&lt;String&gt; request = new HttpEntity&lt;String&gt;(commentJsonObject.toString(), headers);
  RestTemplate restTemplate = new RestTemplate(clientHttpRequestFactory);
  String newCommentString = restTemplate.postForObject(url, request, String.class);
  </code></pre>
  
  <blockquote>
    <p>7org.springframework.web.client.ResourceAccessException: I/O error on POST request for "jirasdtest.myoutotec.com/rest/api/2/issue/SD-1043/comment": connect timed out; nested exception is java.net.SocketTimeoutException: connect timed out at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:744) at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:670)        </p>
  </blockquote>