diff --git a/bundles/org.openhab.binding.valloxmv/pom.xml b/bundles/org.openhab.binding.valloxmv/pom.xml index 81ff314ef2258..017bf618ef7b0 100644 --- a/bundles/org.openhab.binding.valloxmv/pom.xml +++ b/bundles/org.openhab.binding.valloxmv/pom.xml @@ -1,4 +1,6 @@ - + + 4.0.0 diff --git a/bundles/org.openhab.binding.valloxmv/src/main/java/org/openhab/binding/valloxmv/internal/ValloxMVWebSocket.java b/bundles/org.openhab.binding.valloxmv/src/main/java/org/openhab/binding/valloxmv/internal/ValloxMVWebSocket.java index f4d6c07bc4318..5517edaac0d4c 100644 --- a/bundles/org.openhab.binding.valloxmv/src/main/java/org/openhab/binding/valloxmv/internal/ValloxMVWebSocket.java +++ b/bundles/org.openhab.binding.valloxmv/src/main/java/org/openhab/binding/valloxmv/internal/ValloxMVWebSocket.java @@ -25,6 +25,7 @@ import java.util.Map; import java.util.TimeZone; import java.util.concurrent.CountDownLatch; +import java.util.concurrent.Future; import java.util.concurrent.TimeUnit; import org.eclipse.jetty.websocket.api.Session; @@ -81,18 +82,23 @@ public ValloxMVWebSocket(WebSocketClient webSocketClient, ValloxMVHandler voHand } public void request(ChannelUID channelUID, String updateState) { + Future sessionFuture = null; try { socket = new ValloxMVWebSocketListener(channelUID, updateState); ClientUpgradeRequest request = new ClientUpgradeRequest(); logger.debug("Connecting to: {}", destUri); - client.connect(socket, destUri, request); + sessionFuture = client.connect(socket, destUri, request); socket.awaitClose(2, TimeUnit.SECONDS); } catch (InterruptedException | IOException e) { connectionError(e); } catch (Exception e) { logger.debug("Unexpected error"); connectionError(e); + } finally { + if (sessionFuture != null && !sessionFuture.isDone()) { + sessionFuture.cancel(true); + } } }