Skip to content

Commit

Permalink
Revert "[shelly] Always try to stop WebSocketClient (openhab#15719)" (o…
Browse files Browse the repository at this point in the history
…penhab#15720)

This reverts commit 72622a1.

Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
Signed-off-by: Jørgen Austvik <jaustvik@acm.org>
  • Loading branch information
jlaur authored and austvik committed Mar 27, 2024
1 parent 8c23f11 commit a919281
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,10 @@ public void initialize() throws ShellyApiException {
rpcSocket.addMessageHandler(this);
initialized = true;
} else {
logger.debug("{}: Disconnect Rpc Socket on initialize", thingName);
disconnect();
if (rpcSocket.isConnected()) {
logger.debug("{}: Disconnect Rpc Socket on initialize", thingName);
disconnect();
}
}
}

Expand Down Expand Up @@ -1215,7 +1217,9 @@ private void reconnect() throws ShellyApiException {
}

private void disconnect() {
rpcSocket.disconnect();
if (rpcSocket.isConnected()) {
rpcSocket.disconnect();
}
}

public Shelly2RpctInterface getRpcHandler() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,9 @@ public void disconnect() {
s.close(StatusCode.NORMAL, "Socket closed");
session = null;
}
client.stop();
if (client.isStarted()) {
client.stop();
}
} catch (Exception e) {
if (e.getCause() instanceof InterruptedException) {
logger.debug("{}: Unable to close socket - interrupted", thingName); // e.g. device was rebooted
Expand Down

0 comments on commit a919281

Please sign in to comment.