I've read tens of posts in different forums about this subject.
In many times the solution was to upgrade the shield to the latest firmware.
What can I do with this issue, using the latest firmware? I have the typical issue of instability. After a couple of hours, depending of how many requests are made, the shield becomes unresponsive.
The project is a simple REST web server.
The purpose is to respond with JSON if the request is correct REST otherwise a HTTP 400 error.
I post a simplified version of it, so you can see the way I've written the program (apart from the setup(), here is the loop()):
void loop() {
WiFiClient client = server.available();
if (client)
{
if (client.connected())
{
Serial.println("New client:");
String response = client.readString();
Serial.println(response);
// request finished, send response
String command = "";
int index = response.indexOf('\n');
if (index > 0)
{
command = response.substring(0, index - 1);
}
if (command.length() > 0)
{
// Operations: do something
client.println("HTTP/1.1 200 OK\nContent-Type: application/json");
client.println("Content-Length:19\nConnection: close\n");
client.println("{ \"result\":\"OK\" }\n");
// close the connection:
delay(20);
client.stop();
Serial.println("Client disconnected");
return;
}
client.println("HTTP/1.1 400 OK\nContent-Type: text/html");
client.println("Connection: close\n");
client.println("HTTP 400");
// close the connection:
delay(20);
client.stop();
Serial.println("Client disconnected");
}
}
}
Any suggestions are really appreciated!
Greetings