Ethernet shield 2 connexion refused

Hello,
previousely i used an ethernet shield noname and works fine.

for fiablity reason i decided to buy an ethernet shield2.
i use the right library (ethernet2.h) with the same code as previousely.

sometimes (not always) i got the message "connexion refused" from the arduino.

my code is :

#include <SPI.h>
#include <DHT.h>
#include <Ethernet2.h>
...

byte mac[] = {
  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xEA
};
IPAddress ip(192, 168, 1, 178);

byte gateway[] = {
  192, 168, 1, 1
};
// Attachement d'un objet "server" sur le port 1337
EthernetServer server(1337);
...
void setup() {
  Ethernet.begin(mac, ip, gateway);
  server.begin();
...
}

void loop()
{
EthernetClient client = server.available();
  if (client) {
    if (client.connected()) {
      // si le client nous envoie quelque chose
      if (client.available()) {
        // On regarde ce que le client nous demande
        requ[0] = client.read();
        requ[1] = client.read();
        requ[2] = client.read();
...
  }
      }
    }
    delay(20);
    client.stop();
  }
}

could anyone help me ?

could anyone help me ?

If you posted complete code, along with details about what you have connected the ethernet shield to, maybe.

Hi,
thanks for your reply,

the shield is on an offcial arduino mega 2560 board.
it is connected thru ethernet wires to the server (jeedom)

i use the 1.6.13 arduino ide.

the code is attached

ch_hote_20170801.ino (9.72 KB)

it is connected thru ethernet wires to the server

Ethernet shields expect to be connected to routers.