EthernetClient disconnects too early / within GET-request

Hi guys,

I'd like to get some ideas for my troubleshooting-process.
Situation:
Months ago I edited the "Web-Server" communication sketch for the Ethernet-shield, to let my Arduino communicate with my server. Basically I send data via a HTTP GET-Request to my Arduino, get relevant information isolated and pass them on to other functions. So far this works pretty well, and therefor serves as my framework-sketch.
Since then I wrote two different sketches based on that communication-framework. As they are part of a project, I bought for each sketch a separate set of "Arduino Due + Ethernet-Shield". The first "set" was bought in October/November 2013 for the first sketch which controls a little wooden catapult. The second set was bought in February 2014 for the second sketch, which controls a little robot with seven servo-motors.

Problem:
Both of these two sketches work if I'm using the first/older set (catapult) with no cables and motors attached, but not if I'm using the second/newer set (robo): The Robo-Set executes the catapult-sketch properly, but not its own robo-sketch: Printing the incoming GET-Request of the server on the Serial Monitor, reveals that the connection to the server is somehow interrupted (?), as only parts of the request are printed:

arduino is at 123.345.678.900

*** New request from 1 :
GET / HTTP/1.1
Hoclient disconnected

*** New request from 1 :
st: 123.456client disconnected

As you can see, the request is split up and not complete. Sometimes I get more parts, sometimes less, but only a few times I get the whole request.

Now, this is how it should look like:

arduino is at 123.345.678.900

*** New request from 1 :
GET / HTTP/1.1
Host: 123.345.678.901
User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:27.0) Gecko/20100101 Firefox/27.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Connection: keep-alive

*** START: analyze HTTP-GET-Request
[...]

client disconnected

Possible Explanations:
if (client.connected()){ ... } is set to FALSE before the whole request came in

  • client "disconnects" too early because of memory-issues, due to the many variables which the Robo-sketch consists of.
  • second Robo-"Arduino-set" has other firmware then the older one (either DUE or Shield) ?
  • second Robo-"Arduino-set" has less available RAM
  • RAM is somehow flawed
  • damaged Board, DUE or Shield

Questions:

  • Are there different versions of available firmware for the Arduino DUE or the Ethernet-Shield?
  • How is it possible that one set works while the other one doesn't?
  • How can I find out which part DUE or Shield is responsible for this misbehavior?

Additional Information:
I've got another (third) set of Due+Ethernet-Shield, to which I uploaded the Robo-Code when I got confronted with my problem the first time. As far as I remember it worked just once, maybe twice. But then I started mixing the shields and boards to find out which one was defect, and as a result this extra-set doesn't work with the Robo-Code anymore.
The one thing I've not been trying so far is to actually connect the catapult Arduino-Set to the robot-circuit. Why? Because I'm afraid that this "last-one-standing-board" could be damaged as well due to maybe an undetected bug in the robot-circuit.

The ROBO-Code is attached!

I'm really looking forward to your ideas, thanks.

ROBO_Sketch_Forum_Version.zip (6.31 KB)

            client.stop();

            if (client.connect(RApache, 80)) {

The reuse of the client object is not a good idea. Use two different objects for the server functionality and the client functionality.

req_index is never reset, so I'd guess that on the second connection the buffer overruns.

req_index is never reset

It is though, at line 297. I work with OP on the same project, and the thing that still baffles us most is that the code runs on the older Arduino/Ethernet Shield build but not on those two other builds, especially considering that those are newer (but have the same name, just different packacking).

It is though, at line 297.

You're right, I've look over that.

I work with OP on the same project, and the thing that still baffles us most is that the code runs on the older Arduino/Ethernet Shield build but not on those two other builds, especially considering that those are newer (but have the same name, just different packacking).

Do you still have the packaging? Is it an original Arduino or is it a clone (are there already clones of the Due)? Is the Ethernet Shield the same or also a different version? If it's different, what revisions do the two versions have? Can you make pictures of the hardware and post them?