WebClient repeating lasts 16 secs every time?!

Hi there,

since this day, my repeating webclient lasts ~16sec untill to the next loop even if i have set the update interval to 1sec. I just make the arduino (mega 2560 R3) update, is there a correlation to this?

When I use the code example "WebClientRepeating" then it will last 16 seconds too ... what the hell is this?

PS: Since today I have a longer cat5 cable (~10m) .. is there any limitation to the arduino and the cable length?

Thanks a lot for your answeres!!

Robin

napster1989:
I just make the arduino (mega 2560 R3) update

What does that mean?

My crystal ball says it thinks you have also got an Ethernet shield too but it cant tell me what type etc.

PS Ethernet cables should conform to the standards and 10 meters is nothing in terms of what they are capable of.

See HERE

For very long runs you can insert repeaters or hubs.

As for the rest of your question its difficult to make much sense of it.
Maybe include the ACTUAL code your are using (but please use the code tags that look like "</>" on the toolbar.)

Is your sketch successful in fetching the page https://www.arduino.cc/latest.txt? If it is having trouble reaching the website in Italy it might cause a delay.

johnwasser:
https://www.arduino.cc/latest.txt

10601

It's a bit behind the times. I guess they don't bother to update that page.

Hi there,

sorry for the few details. Ok, now i´m back at work and here is it working well! Same code. I think that it is a port forwarding problem maybe. The ethernet shield is made by Wiznet. I think the update was only for the IDE.

But what i dont understand is, the http client could connect to a host but cant send data ... the connection is using the same port, thats creepy ..

For example, with the following code will connect to the webserver every 16 secs @ home. Here at work is a connection every 1 second given. Later, I will check another cable and a specific port forwarding. Then I will reply, so another people may have the same problem (in the future).

The example code is:

/*
  Repeating Web client

 This sketch connects to a a web server and makes a request
 using a Wiznet Ethernet shield. You can use the Arduino Ethernet shield, or
 the Adafruit Ethernet shield, either one will work, as long as it's got
 a Wiznet Ethernet module on board.

 This example uses DNS, by assigning the Ethernet client with a MAC address,
 IP address, and DNS address.

 Circuit:
 * Ethernet shield attached to pins 10, 11, 12, 13

 created 19 Apr 2012
 by Tom Igoe
 modified 21 Jan 2014
 by Federico Vanzati

 http://www.arduino.cc/en/Tutorial/WebClientRepeating
 This code is in the public domain.

 */

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

// assign a MAC address for the ethernet controller.
// fill in your address here:
byte mac[] = {
  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED
};
// fill in an available IP address on your network here,
// for manual configuration:
IPAddress ip(192, 168,  0, 20);

// fill in your Domain Name Server address here:
IPAddress myDns(192, 168, 0, 1);

// initialize the library instance:
EthernetClient client;

char server[] = "www.arduino.cc";
//IPAddress server(64,131,82,241);

unsigned long lastConnectionTime = 0;             // last time you connected to the server, in milliseconds
const unsigned long postingInterval =  1000L; // delay between updates, in milliseconds
// the "L" is needed to use long type numbers

void setup() {
  // start serial port:
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }

  // give the ethernet module time to boot up:
  delay(1000);
  // start the Ethernet connection using a fixed IP address and DNS server:
  Ethernet.begin(mac, ip, myDns);
  // print the Ethernet board/shield's IP address:
  Serial.print("My IP address: ");
  Serial.println(Ethernet.localIP());
}

void loop() {
  // if there's incoming data from the net connection.
  // send it out the serial port.  This is for debugging
  // purposes only:
  if (client.available()) {
    char c = client.read();
    Serial.write(c);
  }

  // if ten seconds have passed since your last connection,
  // then connect again and send data:
  if (millis() - lastConnectionTime > postingInterval) {
    httpRequest();
  }

}

// this method makes a HTTP connection to the server:
void httpRequest() {
  // close any connection before send a new request.
  // This will free the socket on the WiFi shield
  client.stop();

  // if there's a successful connection:
  if (client.connect(server, 80)) {
    Serial.println("connecting...");
    // send the HTTP GET request:
    client.println("GET /latest.txt HTTP/1.1");
    client.println("Host: www.arduino.cc");
    client.println("User-Agent: arduino-ethernet");
    client.println("Connection: close");
    client.println();

    // note the time that the connection was made:
    lastConnectionTime = millis();
  } else {
    // if you couldn't make a connection:
    Serial.println("connection failed");
  }
}

The code looks just fine so as you say it may be a port issue.

It could also be an ISP issue too as some ISP's don't like multiple repeat connects and may throttle a connection identifying it as a "BOT"

That is not the same in an industrial situation where some clients need to repeat connect for small data packets.

Do you really need every second ?

Or could you try getting the DNS from the source eg. router.
Have seen here with multiple Arduinos where I forgot to change the shield IP and it has been colliding with another Arduino and neither worked until I changed the IP.

Unlike an operating system the Arduino cannot tell you there is already an IP with that address and will happily try all day to compete with another IP.