2 x ESP32 and MQTT connection...failed

hi all!
i have a problem in mqtt commuication. I have 2x Esp32, by MQTT they send data to nodered. Both have the same program, deferent IP address. if then work together, noe of them lost connection with MQTT broker. If only one is connect everything is OK, communication is cerrect. Esp cennect by ENC28J60Driver to lan

*
  The classic Arduino WebClient Ethernet example

 This sketch connects to a website (http://arduino.cc) using Ethernet.

 created 18 Dec 2009
 by David A. Mellis
 modified 9 Apr 2012
 by Tom Igoe, based on work by Adrian McEwen

 */

#include <EthernetESP32.h>
#include "PubSubClient.h"


//W5500Driver driver;
ENC28J60Driver driver;
//EMACDriver driver(ETH_PHY_LAN8720);

char server[] = "192.168.0.10";
const char* mqtt_server = "192.168.0.10";
#define CLIENT_ID       "MQTT_2"
#define INTERVAL        1000 // 3 sec delay between publishing

EthernetClient client;
PubSubClient mqttClient(client);
const char* startMessageTopic = "Laser"; 
const char* startMessageTopicCzas = "Laser_Time"; 
unsigned long Start;    
float Lenght;    
float Lenght_s;   
const int SensorPin = 4;  // the number of the pushbutton pin
const int ledPin =  2;    // the number of the LED pin
int SensorState = 0;
int lastSensorState = 0;

// Set the static IP address to use if the DHCP fails to assign
IPAddress ip(192, 168, 0, 102);

// Initialize the Ethernet client library
// with the IP address and port of the server
// that you want to connect to (port 80 is default for HTTP):
//EthernetClient client;
void callback(String topic, byte* message, unsigned int length) {
  Serial.print("Message arrived on topic: ");
  Serial.print(topic);
  Serial.print(". Message: ");
  String messageTemp;
  
  for (int i = 0; i < length; i++) {
    Serial.print((char)message[i]);
    messageTemp += (char)message[i];
  }
}
void setup() {

  Serial.begin(115200);
  delay(500);
  while (!Serial);

  Ethernet.init(driver);

  // start the Ethernet connection:
  Ethernet.begin(ip);
  delay(1000);
  Serial.println("Initialize Ethernet with DHCP:");
     if (Ethernet.hardwareStatus() == EthernetNoHardware) {
      Serial.println("Ethernet shield was not found.  Sorry, can't run without hardware. :(");
      while (true) {
        delay(1); // do nothing, no point running without Ethernet hardware
      }
    }
    if (Ethernet.linkStatus() == LinkOFF) {
      Serial.println("Ethernet cable is not connected.");
    }
    if (Ethernet.linkStatus() == LinkON) {
      Serial.println("Ethernet cable is connected!!.");
    }
    // try to configure using IP address instead of DHCP:
    Ethernet.begin(ip);
    delay(200);
    Serial.println(Ethernet.localIP());
    mqttClient.setCallback(callback);
    mqttClient.setServer(mqtt_server, 1883);
    Serial.println(F("MQTT client configured"));

  
}

void reconnect() {
  // Loop until we're reconnected
  while (!mqttClient.connected()) {
    Serial.print("Attempting MQTT connection...");
    // Attempt to connect
    
  }
}

void loop() {
  if (!mqttClient.connected()) {
    reconnect();
  }
  SensorState= digitalRead(SensorPin);
  if (SensorState != lastSensorState){
    if (SensorState==HIGH){
     digitalWrite(ledPin, HIGH);
    
    mqttClient.publish(startMessageTopic, "false"); 
    Serial.println(F("low"));
    Lenght=((millis()-Start));
    Lenght_s= Lenght*0.001;

    char LenghtString[8];
    dtostrf(Lenght_s, 4, 2, LenghtString);
    mqttClient.publish(startMessageTopic, LenghtString);
    Serial.println(LenghtString);
    Serial.println(Lenght);
    Serial.println(Lenght_s);
    } else {
    // turn LED off
    digitalWrite(ledPin, LOW);
    mqttClient.publish(startMessageTopic, "true"); 
    Serial.println(F("high"));
    Start=millis();
    }
    Dlugosc=0;
  }  
  lastSensorState=SensorState;
  delay(50);
  mqttClient.loop();
}

how can i solve this problem?

Are both using the same CLIENT_ID?

You seem to have taken the PubSubClient mqtt_basic example; but in the reconnect function, all there is under // Attempt to connect is a single blank line. In the original,

void reconnect() {
  // Loop until we're reconnected
  while (!client.connected()) {
    Serial.print("Attempting MQTT connection...");
    // Attempt to connect
    if (client.connect("arduinoClient")) {

is the call to connect, which at a minimum takes a client ID. In the example, it's a hard-coded string. You have a CLIENT_ID macro with a hard-coded value, but it is not used at all in the code posted.

As mentioned, each client ID must be unique. If you connect with an existing ID, the broker may disconnect the previous client. Or when subscribing to a topic, a message may go to just one of the multiple clients using the same ID.

When deploying the same code to multiple devices, one method to get unique IDs is to include the WiFi MAC address (or some derivative) in the client ID. Apparently the ENC28J60 does not have a MAC assigned at the factory -- you just make one up -- so that won't suffice.

That could mean doing #include <WiFi.h> and calling WiFi.macAddress solely for that purpose, adding a good chunk of code to the sketch size. But it is convenient.

HI ALL,
yes both have a different CLIENT ID, and reconnect function also was correct (when i put hear code i delete i... sory) problem was at MAC ADDRESS, probably when i wrote code i put it then, i delete it....

Thanks a lot for all!