Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[tivo] Refresh persistent connection every 12 hours #10824

Merged
merged 1 commit into from
Jun 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public class TiVoBindingConstants {
public static final String BINDING_ID = "tivo";
public static final int CONFIG_SOCKET_TIMEOUT_MS = 1000;
public static final int INIT_POLLING_DELAY_S = 5;
public static final int POLLING_DELAY_12HR_S = 43200;

// List of all Thing Type UIDs
public static final ThingTypeUID THING_TYPE_TIVO = new ThingTypeUID(BINDING_ID, "sckt");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,9 @@ private void startPollStatus() {
};

if (tivoConfigData.isKeepConnActive()) {
// Run once
refreshJob = scheduler.schedule(runnable, INIT_POLLING_DELAY_S, TimeUnit.SECONDS);
// Run once every 12 hours to keep the connection from going stale
refreshJob = scheduler.scheduleWithFixedDelay(runnable, INIT_POLLING_DELAY_S, POLLING_DELAY_12HR_S,
TimeUnit.SECONDS);
logger.debug("Status collection '{}' will start in '{}' seconds.", getThing().getUID(),
INIT_POLLING_DELAY_S);
} else if (tivoConfigData.doPollChanges()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,13 @@ public void statusRefresh() throws InterruptedException {
logger.debug(" statusRefresh '{}' - EXISTING status data - '{}'", tivoConfigData.getCfgIdentifier(),
tivoStatusData.toString());
}

// this will close the connection and re-open every 12 hours
if (tivoConfigData.isKeepConnActive()) {
connTivoDisconnect();
doNappTime();
}

connTivoConnect();
doNappTime();
if (!tivoConfigData.isKeepConnActive()) {
Expand Down