HydraLab icon indicating copy to clipboard operation
HydraLab copied to clipboard

Increase WebSocket reconnect wait time from 10 to 30 seconds

Open Copilot opened this issue 5 months ago • 0 comments
trafficstars

Description

This PR increases the wait time between WebSocket reconnect attempts from 10 seconds to 30 seconds when handling the VIOLATED_POLICY (code 1008) closing code in the AgentWebSocketClient.

Changes Made

  1. Modified AgentWebSocketClient.java to increase the sleep duration between reconnect attempts from 10 seconds to 30 seconds
  2. Updated the related code comment to reflect this change
  3. Updated the log message to indicate 30 seconds sleep time instead of 10 seconds

Details

Changes were made in the onClose method of the AgentWebSocketClient class where it handles the VIOLATED_POLICY case. The longer wait time will reduce reconnection frequency when agents encounter this specific closing code, potentially reducing network load and allowing more time for transient issues to resolve.

// Before:
// wait for 10 seconds and then retry
try {
    log.info("onClose, code: {}, reason: {}, remote: {}, reconnectTime: {}, {} sleep 10 seconds", code, reason, remote, reconnectTime, violatedReconnectTime);
    Thread.sleep(10000);
} catch (InterruptedException e) {
    log.error("onClose, sleep error", e);
}

// After:
// wait for 30 seconds and then retry
try {
    log.info("onClose, code: {}, reason: {}, remote: {}, reconnectTime: {}, {} sleep 30 seconds", code, reason, remote, reconnectTime, violatedReconnectTime);
    Thread.sleep(30000);
} catch (InterruptedException e) {
    log.error("onClose, sleep error", e);
}

Testing

This change makes only a timing modification and doesn't alter any logic or control flow.

Related Issue

This addresses the need to increase sleep duration between reconnection attempts when encountering VIOLATED_POLICY WebSocket close codes.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot avatar May 28 '25 06:05 Copilot