Skip to content

Commit

Permalink
Fix #1417 Change socket mode ping/pong from debug to trace (#1421)
Browse files Browse the repository at this point in the history
  • Loading branch information
seratch authored Jan 15, 2025
1 parent 6a7fe19 commit 7adea91
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -185,15 +185,15 @@ default void initializeSessionMonitorExecutor(long intervalMillis) {
final AtomicLong nextInvocationMillis = new AtomicLong(System.currentTimeMillis());
executorService.scheduleWithFixedDelay(() -> {
long startMillis = System.currentTimeMillis();
if (getLogger().isDebugEnabled()) {
getLogger().debug("Checking the current session...");
if (getLogger().isTraceEnabled()) {
getLogger().trace("Checking the current session...");
}
if (isAutoReconnectEnabled() && nextInvocationMillis.get() <= System.currentTimeMillis()) {
nextInvocationMillis.set(maintainCurrentSession());
}
if (getLogger().isDebugEnabled()) {
if (getLogger().isTraceEnabled()) {
long spentMillis = System.currentTimeMillis() - startMillis;
getLogger().debug("The session maintenance completed in {} milliseconds", spentMillis);
getLogger().trace("The session maintenance completed in {} milliseconds", spentMillis);
}
}, 5_000L, intervalMillis, TimeUnit.MILLISECONDS);
if (getLogger().isDebugEnabled()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,15 +130,15 @@ public void connect() {
public boolean verifyConnection() {
if (this.currentSession != null && this.currentSession.isOpen()) {
try {
if (getLogger().isDebugEnabled()) {
getLogger().debug("Sending a ping message");
if (getLogger().isTraceEnabled()) {
getLogger().trace("Sending a ping message");
}
this.currentSession.sendPing();
long waitMillis = 0L;
while (waitMillis <= 3_000L) {
if (this.currentSession.isPongReceived()) {
if (getLogger().isDebugEnabled()) {
getLogger().debug("Received a pong message");
if (getLogger().isTraceEnabled()) {
getLogger().trace("Received a pong message");
}
return true;
}
Expand All @@ -152,8 +152,8 @@ public boolean verifyConnection() {
e.getMessage()
);
}
if (getLogger().isDebugEnabled()) {
getLogger().debug("Failed to receive a pong message");
if (getLogger().isTraceEnabled()) {
getLogger().trace("Failed to receive a pong message");
}
}
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,8 @@ public void connect() {
public boolean verifyConnection() {
if (this.currentSession != null && this.currentSession.isOpen()) {
String ping = "ping-pong_" + currentSession.getId();
if (getLogger().isDebugEnabled()) {
getLogger().debug("Sending a ping message: {}", ping);
if (getLogger().isTraceEnabled()) {
getLogger().trace("Sending a ping message: {}", ping);
}
ByteBuffer pingBytes = ByteBuffer.wrap(ping.getBytes());
try {
Expand All @@ -199,8 +199,8 @@ public boolean verifyConnection() {
while (waitMillis <= 3_000L) {
String pong = latestPong.getAndSet(null);
if (pong != null && pong.equals(ping)) {
if (getLogger().isDebugEnabled()) {
getLogger().debug("Received a pong message: {}", ping);
if (getLogger().isTraceEnabled()) {
getLogger().trace("Received a pong message: {}", ping);
}
return true;
}
Expand All @@ -213,8 +213,8 @@ public boolean verifyConnection() {
this.currentSession.getId(),
e.getMessage());
}
if (getLogger().isDebugEnabled()) {
getLogger().debug("Failed to receive a pong message: {}", ping);
if (getLogger().isTraceEnabled()) {
getLogger().trace("Failed to receive a pong message: {}", ping);
}
}
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,8 @@ public void connect() {
public boolean verifyConnection() {
if (this.currentSession != null && this.currentSession.isOpen()) {
String ping = "ping-pong_" + currentSession.getId();
if (getLogger().isDebugEnabled()) {
getLogger().debug("Sending a ping message: {}", ping);
if (getLogger().isTraceEnabled()) {
getLogger().trace("Sending a ping message: {}", ping);
}
ByteBuffer pingBytes = ByteBuffer.wrap(ping.getBytes());
try {
Expand All @@ -199,8 +199,8 @@ public boolean verifyConnection() {
while (waitMillis <= 3_000L) {
String pong = latestPong.getAndSet(null);
if (pong != null && pong.equals(ping)) {
if (getLogger().isDebugEnabled()) {
getLogger().debug("Received a pong message: {}", ping);
if (getLogger().isTraceEnabled()) {
getLogger().trace("Received a pong message: {}", ping);
}
return true;
}
Expand All @@ -213,8 +213,8 @@ public boolean verifyConnection() {
this.currentSession.getId(),
e.getMessage());
}
if (getLogger().isDebugEnabled()) {
getLogger().debug("Failed to receive a pong message: {}", ping);
if (getLogger().isTraceEnabled()) {
getLogger().trace("Failed to receive a pong message: {}", ping);
}
}
return false;
Expand Down

0 comments on commit 7adea91

Please sign in to comment.