Skip to content

Increase WebSocket reconnect wait time from 10 to 30 seconds #695

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

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Copilot
Copy link

@Copilot Copilot AI commented May 28, 2025

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 Copilot AI changed the title [WIP] Increase WebSocket reconnect sleep time to 30 seconds Increase WebSocket reconnect wait time from 10 to 30 seconds May 28, 2025
@Copilot Copilot AI requested a review from zhou9584 May 28, 2025 06:58
Copilot finished work on behalf of zhou9584 May 28, 2025 06:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants