Hello guys @Spark,
We are sending HTTP requests continuously from the Spark to a web server (Ubidots), but sometimes the Core just stops sending requests, then flashes red rapidly and then restarts. This happens after ~40-50 loops.
I thought it might be Internet issues, but another user reported the same problem on different networks.
I wrote this code to see after how many requests it fails:
#include "dnsclient/dnsclient.h"
#include "HttpClient/HttpClient.h"
HttpClient http;
char resultstr[64];
#define VARIABLE_ID "5499ba207625421efc176fdc"
#define TOKEN "j2aawKrPRmPRszEbwauSlnJEA2xxxx"
int lightLevel = 0;
http_header_t headers[] = {
{ "Host", "things.ubidots.com" },
{ "Content-Type", "application/json" },
{ "X-Auth-Token" , TOKEN },
{ NULL, NULL }
};
http_request_t request;
http_response_t response;
IPAddress dnsServerIP(8,8,8,8);
IPAddress remote_addr;
DNSClient dns;
char serverName[] = "things.ubidots.com";
void setup() {
pinMode(A0, INPUT);
request.port = 80;
dns.begin(dnsServerIP);
dns.getHostByName(serverName, remote_addr);
request.ip = remote_addr;
request.path = "/api/v1.6/variables/"VARIABLE_ID"/values";
Serial.begin(9600);
}
void loop() {
lightLevel++;
request.body = "{\"value\":" + String(lightLevel) + "}";
http.post(request, response, headers);
Serial.println(response.status);
Serial.println(response.body);
}
Is there a known issue when sending too many requests? or is there a need for a “flush” type of command?
Thanks in advance!