arduino-libraries / ArduinoHttpClient

Arduino HTTP Client library
288 stars 172 forks source link

POST responseStatusCode Hangs #55

Open markreha opened 5 years ago

markreha commented 5 years ago

I am using an Arduino UnO Wifi R2. The following code hangs on my Arduino on the call to responseStatusCode() after running my application anywhere from 12-56 hrs. My HTTP endpoint is a REST API using Java Spring Framework deployed on major Cloud Servers. The hang happens against multiple Cloud Servers that includes Azure, Google, Heroku, and AWS. My JSON payload is very small and I have validated I have no memory leaks in my program. The same REST API and backend code has been running with a Raspberry Pi for almost 12 months.

// Send POST request with JSON to Cloud REST API HttpClient client = HttpClient(wifi, serverAddress, port); client.setHttpResponseTimeout(60 * 1000); client.beginRequest(); client.post(uri); client.sendBasicAuth("MyUsername", "MyPassword"); client.sendHeader("Content-Type", "application/json"); client.sendHeader("Content-Length", json.length()); client.beginBody(); client.print(json); client.endRequest();

// Read the status code and body of the response int statusCode = client.responseStatusCode(); String response = client.responseBody();