Downloading files > 20kb doesn't work UPDATE: it must be WiFi issue...

Back again...

i tried the following with 3 different Boards:

Arduino UNO R3 w/WiFi Shield (official)

#include <SPI.h>
#include <WiFi.h>

#define debug(a) Serial.print(millis()); Serial.print(": "); Serial.println(a);
#define debug2(a, b) Serial.print(millis()); Serial.print(": "); Serial.print(a); Serial.println(b);

void setup(){
  Serial.begin(9600);

char ssid[] = "ssid";     //  your network SSID (name)
char pass[] = "pass";    // your network password

//pinMode(4, OUTPUT);
//digitalWrite(4, HIGH);

// -- Initialize WiFi connection
  int status = WL_IDLE_STATUS;
  status = WiFi.begin(ssid, pass);
  if (status != WL_CONNECTED) {
    Serial.println("No WiFi Connection!");
  }

  // print your local IP address:
  debug2("IP address: ", WiFi.localIP());
}
WiFiClient client;
char* host = "192.168.2.222";
int port = 80;

int totalRequestSize = 0;
int failures = 0;
int requests = 0;

void loop() {
  if (client.connect(host, port)) {
    debug("Connected.");
    client.println("GET /test.file HTTP/1.0");
    client.println("Host: 192.168.2.222");
    client.println();
    int length = 0;
    while(client.connected()) {
      debug("Still connected");
      // the server will close the connection when it is finished sending packets
      while(client.available()) {
        // ...but not until this buffer is empty
        Serial.write(client.read());
        length++;
      }
      debug("Done reading for now...");
    }
    // close your end after the server closes its end
    client.stop();
    
    requests++;
    if (length != totalRequestSize) {
      failures++;
    }
    debug2("Total read: ", length);
    Serial.print("Total failures: "); Serial.print(failures); Serial.print("/"); Serial.println(requests);
  } else {
    debug("Couldn't connect.");
  }
  delay(10000);
}

Arduino UNO R3 w/Ethernet Shield (official)

#include <SPI.h>
#include <Ethernet.h>

byte mac[] = { 0x90, 0xA2, 0xDA, 0x0D, 0x4C, 0x75 }; //physical mac address UNO R3 EthernetShield
EthernetClient client;

#define debug(a) Serial.print(millis()); Serial.print(": "); Serial.println(a);
#define debug2(a, b) Serial.print(millis()); Serial.print(": "); Serial.print(a); Serial.println(b);

void setup(){
  Serial.begin(9600);

  // start the Ethernet connection:
  if (Ethernet.begin(mac) == 0) {
    debug("DHCP Failed");
    // no point in carrying on, so do nothing forevermore:
    while(true);
  }
  // print your local IP address:
  debug2("IP address: ", Ethernet.localIP());
}

char* host = "192.168.2.222";
int port = 80;

int totalRequestSize = 0;
int failures = 0;
int requests = 0;

void loop() {
  if (client.connect(host, port)) {
    debug("Connected.");
    client.println("GET /test.file HTTP/1.0");
    client.println("Host: 192.168.2.222.net");
    client.println();
    int length = 0;

    while(client.connected()) {
      debug("Still connected");
      // the server will close the connection when it is finished sending packets
      while(client.available()) {
        // ...but not until this buffer is empty
        Serial.write(client.read());
        length++;
      }
      debug("Done reading for now...");
    }
    // close your end after the server closes its end
    client.stop();
    
    requests++;
    if (length != totalRequestSize) {
      failures++;
    }
    debug2("Total read: ", length);
    Serial.print("Total failures: "); Serial.print(failures); Serial.print("/"); Serial.println(requests);
  } else {
    debug("Couldn't connect.");
  }
  delay(1000);
}

Arduino Ethernet(official)

same as above with different MAC

Testfile

Results:

UNO R3 w/WiFi Shield

Total read: 14467 - missing bytes (any loop)

Last two lines from Serial Output:
3AAAAAABBBBBBBCCCCCCDDDDDDDDEEEEEEFFFFFFGGGGGHHHHHHIIIIIIJJJJJJJKKKKKKKLLLLLLLMMMMMMNNNNNOOOOOPPPPPPQQQQQQRRRRSSSSSTTTTTUUUUUVVVVVWWWWWXXXXXYYYYYYZZZZZ
EOF EOF

The last line is available but between some lines gets lost....

[b][u]With [/u][/b]
pinMode(4, OUTPUT);
digitalWrite(4, HIGH);

7AAAAAABBBBBBBCCCCCCDDDDDDDDEEEEEEEFFFFFFGGGGGHHHHHHIIIIIIJJJJJJJKKKKKKKLLLLLLLMMMMMMNNNNNOOOOOPPPPPPQQQQQQRRRRSSSSSTTTTTUUUUUVVVVVWWWWWXXXXXYYYYYYZZZZZ
8AAAAAABBBBBBBCCCCCCDDDDDDDDEEEEEEEFFFFFFGGGGGHHHHHHIIIIIIJJJJJJJKKKKKKKLLLLLLLMMMMMMNNNNNOOOOOPPPPPPQQQQQQRRRRSSSSSTTTTTUUUUUVVEEEEEEFFFFFFGGGGGHHHHHHIIIIIIJJJJJJJKKKKKKKLLLLLLLMMMMMMNNNNNOOOOOPPPPPPQQQQQQRRRRSSSSSTTTTTUUUUUVVVVVWWWWWXXXXXYYYYYYZZZZZ
EOF EOF
Total read: 13955

UNO R3 w/Etnerhet Shield

Total read: 27779 - complete expected length (any loop)

Arduino Ethernet

Total read: 27779 - complete expected length (any loop)

Summary:

What i can exclude:

-WiFi Network ( I tried different router an different networks (Netgear, AVM, Cisco))
-UNO R3 (as it works with the Ethernet Shield without any problem)
-SD Card (as i disabled it and doesnt include any SD libraray)
-Content Server (as it works with the Arduino Ethernet and UNO R3 w/Ethernet Shield)

Conclusion:

There must be something wrong with the WiFi Connection / WiFi Library,
so i hope my debugging can lead someone to an solution?
Maybe i do something wrong or missed something else?!

Hopefully someone can lead me to the right direction!

Thanks a lot!

-andreas