Skip to content

Auto reconnect to log service, added buffering for logs for latest version#664

Merged
Muntasib-creator merged 2 commits intodevfrom
multi-client-support-faster
Feb 25, 2026
Merged

Auto reconnect to log service, added buffering for logs for latest version#664
Muntasib-creator merged 2 commits intodevfrom
multi-client-support-faster

Conversation

@mahbd
Copy link
Collaborator

@mahbd mahbd commented Feb 25, 2026

PR Type

Refactor/Feature

PR Checklist

  • Tests for the changes have been added / updated.
  • Documentation comments have been added / updated.
  • A changelog entry has been made.
  • Version number has been updated.
  • Required modules have been added to respective "requirements*.txt" files.
  • Relevant Test Cases added to this description (below).
  • (Team) Label with affected action categories and semver status.

Overview

This PR refactors the live_log_service.py module to implement robust WebSocket reconnection logic with exponential backoff and introduces log buffering when connected to a server version 2.0.0 or later.

The core changes are:

  1. Auto Reconnect: The WebSocket connection is now managed within a dedicated daemon thread (run_ws_thread) that continuously attempts to reconnect upon failure or close, utilizing an exponential backoff strategy (MIN_RECONNECT_DELAY_SECONDS to MAX_RECONNECT_DELAY_SECONDS).
  2. Server Version Awareness: Upon connection, the client now expects a version message from the server. If the server reports version 2.0.0 or higher, log messages are no longer sent individually but collected into a buffer.
  3. Log Buffering: Logs are batched and flushed every 0.5 seconds or when the buffer reaches 500 entries. This reduces individual WebSocket traffic for newer server versions.
  4. Server Change Handling: If connect() is called with a new URL, the existing connection is immediately closed to switch to the new server instance.
  5. Server Version Reset: The server_version is reset to None upon connection closing/failure, aligning with the "reset server version on server change" commit.

This enhancement improves stability during transient network issues and optimizes log transmission for modern server deployments.

Test Cases

  • Verified that the connection thread manages re-attempts correctly when the WebSocket is manually closed or fails to connect initially.
  • Verified that individual logs are sent when the server version is less than (2, 0, 0).
  • Verified that logs are buffered and flushed in batches when the server version is (2, 0, 0) or greater.

@mahbd
Copy link
Collaborator Author

mahbd commented Feb 25, 2026

📚 $\text{Stack Overview}$

Pulls submitted in this stack:

This comment was automatically generated by st.

@mahbd mahbd marked this pull request as ready for review February 25, 2026 01:45
@mdshakib007 mdshakib007 self-requested a review February 25, 2026 02:28
Copy link
Collaborator

@mdshakib007 mdshakib007 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Muntasib-creator Muntasib-creator merged commit fcdc77e into dev Feb 25, 2026
7 checks passed
@Muntasib-creator Muntasib-creator deleted the multi-client-support-faster branch February 25, 2026 08:51
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.

3 participants