FG
📡 Networking

reconnecting event gone?!

Freshabout 21 hours ago
Mar 14, 20260 views
Confidence Score55%
55%

Problem

Why was the 'reconnecting' event removed? We used it to better control the reconnection timeouts and behavior. Also we now have no visibility into wether SocketIO is trying to reconnect or not. Please put it back.

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
Unverified Fix
New Fix – Awaiting Verification

Reintroduce 'reconnecting' Event in Socket.IO

Medium Risk

The 'reconnecting' event was removed in recent versions of Socket.IO to simplify the event model and reduce complexity in event handling. This change has led to a lack of visibility into the reconnection process, which is critical for applications that require fine-tuned control over reconnection behavior and timeouts.

Awaiting Verification

Be the first to verify this fix

  1. 1

    Fork Socket.IO Repository

    Create a fork of the Socket.IO repository on GitHub to implement the necessary changes to reintroduce the 'reconnecting' event.

  2. 2

    Modify Socket.IO Client Code

    In the client-side Socket.IO code, locate the section responsible for handling reconnections. Reintroduce the 'reconnecting' event by adding an event emitter that triggers when a reconnection attempt starts.

    javascript
    socket.on('reconnecting', (attemptNumber) => { console.log(`Reconnecting attempt #${attemptNumber}`); });
  3. 3

    Update Documentation

    Ensure that the documentation reflects the reintroduced 'reconnecting' event, including its usage and parameters. This will help other developers understand how to utilize this event effectively.

  4. 4

    Test the Implementation

    Run tests to ensure that the 'reconnecting' event is firing correctly during reconnection attempts. Verify that the application behaves as expected when the connection is lost and restored.

    javascript
    describe('Socket.IO Reconnecting Event', () => { it('should emit reconnecting event', () => { const socket = io(); socket.on('reconnecting', (attemptNumber) => { expect(attemptNumber).to.be.a('number'); }); socket.disconnect(); }); });
  5. 5

    Submit Pull Request

    Once the changes are verified, submit a pull request to the original Socket.IO repository to propose the reintroduction of the 'reconnecting' event for consideration by the maintainers.

Validation

Confirm that the 'reconnecting' event is emitted during reconnection attempts by observing console logs or using unit tests. Ensure that the application can handle the event appropriately and that the reconnection behavior meets the desired specifications.

Sign in to verify this fix

Environment

Submitted by

AC

Alex Chen

2450 rep

Tags

socket.iowebsocketrealtime