diff --git a/bundles/org.openhab.binding.wemo/src/main/java/org/openhab/binding/wemo/internal/handler/WemoHandler.java b/bundles/org.openhab.binding.wemo/src/main/java/org/openhab/binding/wemo/internal/handler/WemoHandler.java index 1e094266d263d..25efd72b1a745 100644 --- a/bundles/org.openhab.binding.wemo/src/main/java/org/openhab/binding/wemo/internal/handler/WemoHandler.java +++ b/bundles/org.openhab.binding.wemo/src/main/java/org/openhab/binding/wemo/internal/handler/WemoHandler.java @@ -17,12 +17,6 @@ import java.io.IOException; import java.math.BigDecimal; import java.math.RoundingMode; -import java.net.ConnectException; -import java.net.InetSocketAddress; -import java.net.NoRouteToHostException; -import java.net.Socket; -import java.net.SocketAddress; -import java.net.SocketTimeoutException; import java.net.URL; import java.time.Instant; import java.time.ZonedDateTime; @@ -49,6 +43,7 @@ import org.eclipse.smarthome.core.types.Command; import org.eclipse.smarthome.core.types.RefreshType; import org.eclipse.smarthome.core.types.State; +import org.eclipse.smarthome.io.net.http.HttpUtil; import org.eclipse.smarthome.io.transport.upnp.UpnpIOParticipant; import org.eclipse.smarthome.io.transport.upnp.UpnpIOService; import org.openhab.binding.wemo.internal.http.WemoHttpCall; @@ -480,20 +475,20 @@ public String getWemoURL(String actionService) { } } wemoURL = "http://" + host + ":" + port + "/upnp/control/" + actionService + "1"; + logger.trace("WeMo url {}", wemoURL); return wemoURL; } return wemoURL; } - public boolean servicePing(String host, int port) throws IOException { - SocketAddress socketAddress = new InetSocketAddress(host, port); - try (Socket socket = new Socket()) { - logger.trace("Ping WeMo device at '{}'", socketAddress); - socket.connect(socketAddress, 250); - return true; - } catch (ConnectException | SocketTimeoutException | NoRouteToHostException ignored) { + public boolean servicePing(String host, int port) { + logger.trace("Ping WeMo device at '{}:{}'", host, port); + try { + HttpUtil.executeUrl("GET", "http://" + host + ":" + port, 250); + } catch (IOException e) { return false; } + return true; } @Override