My HttpClient is only sending two requests. The server receives, returns the 2 values but it is actually a loop that sends a lot of times! Can anyone help me?
public static void main(String[] args) throws IOException, InterruptedException {
SendData sender = new SendData();
String JsonDeDados;
String infos = "informacoes";
HttpClient client = HttpClientBuilder.create().build();
CloseableHttpClient clientclose = HttpClients.createDefault();
HttpPost post = new HttpPost("http://localhost:5030/data");
do {
JsonDeDados = sender.sendMessageDATA();
List<NameValuePair> urlParameters = new ArrayList<NameValuePair>();
urlParameters.add(new BasicNameValuePair(infos, JsonDeDados));
StringEntity entity = new StringEntity(JsonDeDados);
post.setEntity(entity);
post.setHeader("Content-Type", "application/json");
CloseableHttpResponse response = (CloseableHttpResponse) client.execute(post);
System.out.println("Código da Resposta: " + response.getStatusLine().getStatusCode());
clientclose.close();
Thread.sleep(1000);
}while(true);
}