From 5ae87b8dee502c4d402eca4a578240ed82f08378 Mon Sep 17 00:00:00 2001 From: stefan-hoehn Date: Mon, 19 Aug 2024 09:18:07 +0200 Subject: [PATCH] [govee] make socket close more resilient (#17286) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * [govee] make socket close more resilient Signed-off-by: Stefan Höhn --- .../binding/govee/internal/CommunicationManager.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/bundles/org.openhab.binding.govee/src/main/java/org/openhab/binding/govee/internal/CommunicationManager.java b/bundles/org.openhab.binding.govee/src/main/java/org/openhab/binding/govee/internal/CommunicationManager.java index 4028c425e26..c8cdee364b4 100644 --- a/bundles/org.openhab.binding.govee/src/main/java/org/openhab/binding/govee/internal/CommunicationManager.java +++ b/bundles/org.openhab.binding.govee/src/main/java/org/openhab/binding/govee/internal/CommunicationManager.java @@ -200,7 +200,12 @@ public class CommunicationManager { socket.setReuseAddress(true); while (!stopped) { DatagramPacket packet = new DatagramPacket(buffer, buffer.length); - socket.receive(packet); + if (!socket.isClosed()) { + socket.receive(packet); + } else { + logger.warn("Socket was unexpectedly closed"); + break; + } if (stopped) { break; }