W5100 webclient problem on specific network

Hello,

I have a function code for the Web client that works without a problem on the network at home. When I move to the network in my work as it works, just a momentary jams. Every second reading simple web page, and listing its contents to the serial. In this network becomes in about 5-60 seconds to get back connection failed in step:

if (client.connect(server, 80)) { // Serial.println("connected"); client.println(text); client.println("Host: _server__"); client.println(); client.println("Connection: close"); return readPage(); }else{ Serial.println("connection failed");

Arduino was then stopped for about 15 seconds, before continuing in loop. Ping to the server and to the Arduino seems to be without any problems and the network is stable .. Has anyone seen anything like this? Thanks for any advice

A snippet is not enough to determine your problem. Post all your code. User the code tags.

OK … I shortened 1200 lines of code, to be a little clearer. Error, but continues.
I just wanted to point out that I do not think there is a problem in the code.
When I connect this code to the internet at home so everything works.
The problem looks like it was an error in Ethernet.
But pings are absolutely right, and I also tried to replace the mega and ethernet shield.

Attached is the code.

sketch_dec01a1c.ino (10.7 KB)

That code is atrocious.

if (nactiip > 2) {nactiip = 0; offline = 1;Serial.println("offline zapnout");

Get your enter key fixed.

Learn to use Tools + Auto Format. Code that wanders all over the page like a drunken sailor does not inspire confidence.

  String text = "GET /rh/risa/test.php HTTP/1.1";

There is NO excuse for wrapping this string in a String instance, pissing away resources uselessly.

Don't you think that readPage() should confirm that there is a client connected?

Why does readPage() zero out the char array inString, and then collect all the data in a String?

I know it's not nice code. It's a draft, which I'm very quick to cut short so defined many variables that are not used.

My problem with 15-30 seconds of stopping communication is connectAndRead (), because after a long wait I get "chyba spojeni" (EN= "Connection error")

How do you think I should check client connections readPage ()?

Once again I apologize for chaotic code

How do you think I should check client connections readPage ()?

String readPage()
{
   String data = "";
   if(client.connected())
   {
      // All the rest of the code that was in readPage goes here
   }
   return data;
}

Thanks, I have used this check. But it does not solve my problem. The error happens when you have client.connect. I post here as I get on the console. Note the number 1 - it is the first communication error. Then again, it works. It's random.

Odezva serveru v case: 11ms
Socket#0:0x22 8888 D:0.0.0.0(0)
Socket#1:0x0 49182 D:91.239.201.17(80)
Socket#2:0x0 0 D:0.0.0.0(0)
Socket#3:0x0 0 D:0.0.0.0(0)
data jsou : 00000000000
Odezva serveru v case: 12ms
Socket#0:0x22 8888 D:0.0.0.0(0)
Socket#1:0x0 49183 D:91.239.201.17(80)
Socket#2:0x0 0 D:0.0.0.0(0)
Socket#3:0x0 0 D:0.0.0.0(0)
data jsou : 00000000000
chyba spojeni
1
Socket#0:0x22 8888 D:0.0.0.0(0)
Socket#1:0x0 49184 D:91.239.201.17(80)
Socket#2:0x0 0 D:0.0.0.0(0)
Socket#3:0x0 0 D:0.0.0.0(0)
data jsou : 00000000000
Odezva serveru v case: 17ms
Socket#0:0x22 8888 D:0.0.0.0(0)
Socket#1:0x0 49185 D:91.239.201.17(80)
Socket#2:0x0 0 D:0.0.0.0(0)
Socket#3:0x0 0 D:0.0.0.0(0)
data jsou : 00000000000
Odezva serveru v case: 12ms
Socket#0:0x22 8888 D:0.0.0.0(0)
Socket#1:0x0 49186 D:91.239.201.17(80)
Socket#2:0x0 0 D:0.0.0.0(0)
Socket#3:0x0 0 D:0.0.0.0(0)
data jsou : 00000000000