Skip to content

Commit a3503ef

Browse files
committed
fix: update timings for server monitor to meet stream close time policy
1 parent a882d1b commit a3503ef

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/StreamingSubscriberConnection.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ final class StreamingSubscriberConnection extends AbstractApiService implements
134134
private static final Duration CLIENT_PING_INTERVAL = Duration.ofSeconds(30);
135135
private ScheduledFuture<?> pingSchedulerHandle;
136136

137-
private static final Duration SERVER_MONITOR_INTERVAL = Duration.ofSeconds(15);
137+
private static final Duration SERVER_MONITOR_INTERVAL = Duration.ofSeconds(10);
138138
private static final Duration SERVER_PING_TIMEOUT_DURATION = Duration.ofSeconds(15);
139139
private final AtomicLong lastServerResponseTime;
140140
private final AtomicLong lastClientPingTime;
@@ -480,7 +480,7 @@ private void startClientPinger() {
480480
logger.log(Level.FINE, "Error sending client keepalive ping", e);
481481
}
482482
},
483-
CLIENT_PING_INTERVAL.getSeconds(),
483+
0,
484484
CLIENT_PING_INTERVAL.getSeconds(),
485485
TimeUnit.SECONDS);
486486
}
@@ -514,13 +514,13 @@ private void startServerMonitor() {
514514
}
515515

516516
Duration elapsedSincePing = Duration.ofNanos(now - lastPing);
517-
if (elapsedSincePing.compareTo(SERVER_PING_TIMEOUT_DURATION) <= 0) {
517+
if (elapsedSincePing.compareTo(SERVER_PING_TIMEOUT_DURATION) < 0) {
518518
return;
519519
}
520520

521521
logger.log(
522522
Level.WARNING,
523-
"No response from server for {0} seconds. Closing stream.",
523+
"No response from server for {0} seconds since last ping. Closing stream.",
524524
elapsedSincePing.getSeconds());
525525

526526
lock.lock();

0 commit comments

Comments
 (0)