I have done this for the past couple of years without problem: Log data on fixed interval, send HTTP POST requests to a server and wait for it to respond. I extract one thing out of it and move on to log data.
But lately (I've not upgraded Arduino IDE or hardware or firmware), I have been getting partial server responses like:
HTTP/1.1 500 Internal Server Error
Date: Tue, 08 Jul 2014 20:34:22 GMT
The connection times out after about 10-18 seconds, less than my software time out of 30s in a while loop.
Then after next connection is established, I get this:
Server: Apache/2.2.22 (Ubuntu)
Vary: Accept-Encoding
Content-Length: 619
Connection: close
Content-Type: text/html; charset=iso-8859-1
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>500 Internal Server Error</title>
</head><body>
<h1>Internal Server Error</h1>
<p>The server encountered an internal error or
misconfiguration and was unable to complete
your request.</p>
<p>Please contact the server administrator,
[no address given] and inform them of the time the error occurred,
and anything you might have done that may have
caused the error.</p>
<p>More information about this error may be available
in the server error log.</p>
<hr>
<address>Apache/2.2.22 (Ubuntu) Server at www.-------.com Port 80</address>
</body></html>
HTTP/1.1 200 OK
Date: Tue, 08 Jul 2014 20:34:35 GMT
Server: Apache/2.2.22 (Ubuntu)
Vary: Accept-Encoding
Keep-Alive: timeout=5, max=100
Apparently only the first 2 lines of the 500 error response was received during the first connection. Then minutes later, next upload gets the rest of the first response and with the second response (not complete either).
I wonder if I am to be blamed. I use:
if (!client.connected()) break;
This breaks out of a while loop that waits for server response.
What if server breaks connection when there is still unread message in the wifi shield? This will just make arduino quit reading the unread message and it gets left over for the next connection. This explanation contrasts my understand:
I am not using the "LATEST" version of the library which this reference is about though.
Any simple explanations? I'll try to compile in arduino ide 1.0.5 r2 to see what happens.