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

[gardena] Eliminate frequent web service re-starting #13238

Merged
merged 3 commits into from
Aug 12, 2022
Merged
Show file tree
Hide file tree
Changes from 2 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 @@ -215,7 +215,6 @@ private <T> T executeRequest(HttpMethod method, String url, @Nullable Object con
final PostOAuth2Response token = this.token;
if (token != null) {
request.header("Authorization", token.tokenType + " " + token.accessToken);
request.header("Authorization-provider", token.provider);
}
request.header("X-Api-Key", config.getApiKey());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ public synchronized void stop() {
final ScheduledFuture<?> connectionTracker = this.connectionTracker;
if (connectionTracker != null) {
connectionTracker.cancel(true);
this.connectionTracker = null;
}

logger.debug("Closing Gardena Webservice ({})", socketId);
Expand Down Expand Up @@ -121,11 +122,12 @@ public void onConnect(Session session) {

ScheduledFuture<?> connectionTracker = this.connectionTracker;
if (connectionTracker != null && !connectionTracker.isCancelled()) {
connectionTracker.cancel(false);
connectionTracker.cancel(true);
this.connectionTracker = null;
andrewfg marked this conversation as resolved.
Show resolved Hide resolved
}

// start sending PING every two minutes
this.connectionTracker = scheduler.scheduleWithFixedDelay(this::sendKeepAlivePing, 2, 2, TimeUnit.MINUTES);
this.connectionTracker = scheduler.scheduleWithFixedDelay(this::sendKeepAlivePing, 1, 2, TimeUnit.MINUTES);
andrewfg marked this conversation as resolved.
Show resolved Hide resolved
}

@OnWebSocketFrame
Expand Down