Hi to all, @heligone i have tested the sketch of @Marcussacapuces91, and and reproduced the issue, now i take some modifications like introducing a timeout and impose a client.close() and a client.flush() after the put request, the code that i use is the following:
/*
Simple PUT client for ArduinoHttpClient library
Connects to server once every five seconds, sends a PUT request
and a request body
created 14 Feb 2016
by Tom Igoe
update by M. Sibert May 2018
this example is in the public domain
*/
#include <MKRGSM.h>
#include <ArduinoHttpClient.h>
#include "arduino_secrets.h"
const String serverName(("httpbin.org"));//F("httpbin.org"));
const unsigned serverPort = 80;
const String servicePath(("/put"));//F("/put"));
const String GPRS_APN((APN_NAME));//F(APN_NAME));
const String GPRS_LOGIN((APN_USERNAME));//F(APN_USERNAME));
const String GPRS_PASSWORD((APN_PASSWORD));//F(APN_PASSWORD));
unsigned long initTime = millis();
GSM gsm(true);
GPRS gprs;
GSMClient gprsClient;
HttpClient client = HttpClient(gprsClient, serverName, serverPort);
const String contentType = "application/json";
const String putData = "{ \"name\": \"light\", \"age\": 46 }";
void setup() {
Serial.begin(9600);
MODEM.begin();
boolean connected = false;
while (!connected) {
if ((gsm.begin(PIN_CODE) == GSM_READY) &&
(gprs.attachGPRS(GPRS_APN.c_str(), GPRS_LOGIN.c_str(), GPRS_PASSWORD.c_str()) == GPRS_READY)) {
connected = true;
} else {
Serial.println("Not connected");
delay(1000);
}
}
Serial.println("Connected");
}
unsigned long int count = 0;
void loop() {
Serial.println("Making PUT request");
int ret = client.put(servicePath.c_str(), contentType, putData);
if (ret < 0) {
client.flush();
client.stop();
return;
}
unsigned long looptime = millis();
while (client.available() <= 0 || millis() - looptime < 5000) {
}
// read the status code and body of the response
const int statusCode = client.responseStatusCode();
const String response = client.responseBody();
if (statusCode != 200) {
client.flush();
client.stop();
} else {
Serial.print("Status code: ");
Serial.println(statusCode);
Serial.print("Response: ");
Serial.println(response);
Serial.print(count);
count++;
}
Serial.print("battery charge: ");
Serial.println(String(analogRead(ADC_BATTERY)));
unsigned long start = millis();
Serial.print("Time ");
Serial.println((millis() - initTime) / 1000);
while (client.connected())
{
Serial.println("Connected!!!");
delay(100);
if (millis() - start > 5000)
{
client.flush();
client.stop();
}
}
}
In my test it run for 3 hours and put around 1000 of request, could you try and let me now if works?, while i proceed to test it more and more, another things could you share the log of the debug mode?