     } else {
       client.loop();
     }
+  } else {
+    if (client.connected())
+      client.disconnect();
   }
   static unsigned long tock = 0;
 

    else // U_SPIFFS
      type = "filesystem";

    // NOTE: if updating SPIFFS this would be the place to unmount SPIFFS using SPIFFS.end()
    Serial.println("Start updating " + type);
  });

  ArduinoOTA.onEnd([]() {
    Serial.println("\nEnd");
  });

  ArduinoOTA.onError([](ota_error_t error) {

  ota = true;
}

String DisplayIP4Address(IPAddress address)
{
  return String(address[0]) + "." +
         String(address[1]) + "." +
         String(address[2]) + "." +
         String(address[3]);
}
String connectionDetailsString() {
  return "Wired Ethernet: " + ETH.macAddress() +
         ", IPv4: " + DisplayIP4Address(ETH.localIP()) + ", " +
         ((ETH.fullDuplex()) ? "full" : "half") + "-duplex, " +
         String(ETH.linkSpeed()) + " Mbps.";
}

void WiFiEvent(WiFiEvent_t event)
{
  switch (event) {
