This reverts commit 72622a1409.
Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
This commit is contained in:
@@ -141,8 +141,10 @@ public class Shelly2ApiRpc extends Shelly2ApiClient implements ShellyApiInterfac
|
|||||||
rpcSocket.addMessageHandler(this);
|
rpcSocket.addMessageHandler(this);
|
||||||
initialized = true;
|
initialized = true;
|
||||||
} else {
|
} else {
|
||||||
logger.debug("{}: Disconnect Rpc Socket on initialize", thingName);
|
if (rpcSocket.isConnected()) {
|
||||||
disconnect();
|
logger.debug("{}: Disconnect Rpc Socket on initialize", thingName);
|
||||||
|
disconnect();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1215,7 +1217,9 @@ public class Shelly2ApiRpc extends Shelly2ApiClient implements ShellyApiInterfac
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void disconnect() {
|
private void disconnect() {
|
||||||
rpcSocket.disconnect();
|
if (rpcSocket.isConnected()) {
|
||||||
|
rpcSocket.disconnect();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Shelly2RpctInterface getRpcHandler() {
|
public Shelly2RpctInterface getRpcHandler() {
|
||||||
|
|||||||
@@ -211,7 +211,9 @@ public class Shelly2RpcSocket {
|
|||||||
s.close(StatusCode.NORMAL, "Socket closed");
|
s.close(StatusCode.NORMAL, "Socket closed");
|
||||||
session = null;
|
session = null;
|
||||||
}
|
}
|
||||||
client.stop();
|
if (client.isStarted()) {
|
||||||
|
client.stop();
|
||||||
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
if (e.getCause() instanceof InterruptedException) {
|
if (e.getCause() instanceof InterruptedException) {
|
||||||
logger.debug("{}: Unable to close socket - interrupted", thingName); // e.g. device was rebooted
|
logger.debug("{}: Unable to close socket - interrupted", thingName); // e.g. device was rebooted
|
||||||
|
|||||||
Reference in New Issue
Block a user