Skip to content

Increase WebSocket reconnect retry limit from 5 to 10 on agent side #694

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 WebSocket reconnect retry attempts on the agent side when the connection is closed with code 1008 (VIOLATED_POLICY) from 5 to 10. This change allows the agent to make more reconnection attempts before exiting, improving resilience during temporary network issues.

Changes made

  • Modified the condition check in AgentWebSocketClient.java from violatedReconnectTime > 5 to violatedReconnectTime > 10
  • Added a comment to clearly document the reconnection retry logic

Why these changes

When the WebSocket connection is closed with code 1008 (VIOLATED_POLICY), the agent previously would only attempt to reconnect 5 times before exiting. This limit was too low for environments with less stable connections. By increasing the retry limit to 10, we provide more opportunity for the agent to recover from temporary network disruptions before giving up.

Testing

The change is a simple value modification and doesn't require special testing beyond the existing test suite.

// Before:
if(violatedReconnectTime > 5) {
    log.error("onClose, code: {}, reason: {}, remote: {}, reconnectTime: {}, {}", code, reason, remote, reconnectTime, violatedReconnectTime);
    System.exit(code);
}

// After:
// Allow up to 10 reconnect attempts before exiting
if(violatedReconnectTime > 10) {
    log.error("onClose, code: {}, reason: {}, remote: {}, reconnectTime: {}, {}", code, reason, remote, reconnectTime, violatedReconnectTime);
    System.exit(code);
}

💡 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.

@zhou9584
Copy link
Contributor

@copilot Modify the violatedReconnectTime condition in onClose() method from 5 to 10

Co-authored-by: zhou9584 <26757995+zhou9584@users.noreply.github.com>
@Copilot Copilot AI changed the title [WIP] Increase WebSocket reconnect retry times on agent side to 10 Increase WebSocket reconnect retry limit from 5 to 10 on agent side May 28, 2025
@Copilot Copilot AI requested a review from zhou9584 May 28, 2025 06:52
Copilot finished work on behalf of zhou9584 May 28, 2025 06:52
Copy link
Author

Copilot AI commented May 28, 2025

@copilot Modify the violatedReconnectTime condition in onClose() method from 5 to 10

This change has been completed in commit d5a0fe9. The violatedReconnectTime condition in the onClose() method has been modified from 5 to 10.

Copilot finished work on behalf of zhou9584 May 28, 2025 06:54
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