A quick look at your code and I cannot see any particular problem with it but maybe you should also check the Ethernet connection is up before checking if the MQTT connection is up as the problem might be there instead of the MQTT connection.
If your using DHCP then maybe the lease has expired and you need to reconnect or it's just a funny with the Ethernet connection.
I use ESP8266/ESP32 sensors and I have also had it where the WiFi router just stops accepting connections from a particular device or it drops connection.
Another thing to do might be to reset the Arduino in code if connection fails.