Skip to content

Commit

Permalink
[tradfri] Do a dispose() and initialize() when loosing contact with G…
Browse files Browse the repository at this point in the history
…W. (openhab#7291)

Fixes openhab#7152.

Signed-off-by: Jan Gustafsson <[email protected]>
  • Loading branch information
jannegpriv authored and andrewfg committed Aug 31, 2020
1 parent 9510b84 commit ab4effc
Showing 1 changed file with 3 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import static org.openhab.binding.tradfri.internal.TradfriBindingConstants.*;

import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.Collection;
Expand Down Expand Up @@ -352,10 +351,9 @@ private synchronized void requestDeviceDetails(String instanceId) {
public void setStatus(ThingStatus status, ThingStatusDetail statusDetail) {
// to fix connection issues after a gateway reboot, a session resume is forced for the next command
if (status == ThingStatus.OFFLINE && statusDetail == ThingStatusDetail.COMMUNICATION_ERROR) {
logger.debug("Gateway communication error. Forcing session resume on next command.");
TradfriGatewayConfig configuration = getConfigAs(TradfriGatewayConfig.class);
InetSocketAddress peerAddress = new InetSocketAddress(configuration.host, configuration.port);
this.dtlsConnector.forceResumeSessionFor(peerAddress);
logger.debug("Gateway communication error. Forcing a re-initialization!");
dispose();
initialize();
}

// are we still connected at all?
Expand Down

0 comments on commit ab4effc

Please sign in to comment.