Skip to content

Conversation

@lilfaf
Copy link
Contributor

@lilfaf lilfaf commented Dec 12, 2025

PR #139 incorrectly changed the WebSocket close code for graceful server shutdown from 4200 to 4009, breaking pusher-js auto-reconnect behavior.

According to Pusher protocol:

  • 4000-4099: Client SHOULD NOT reconnect (auth failures, unauthorized)
  • 4200-4299: Client SHOULD reconnect immediately (server going away)

Code 4009 means "Connection is unauthorized" which tells clients not to reconnect. The fix restores 4200 for server shutdown, matching Soketi's behavior.

Note: terminate_user_connections keeps 4009 as this is for API-initiated user termination where the app deliberately kicks users - this matches Soketi and is correct behavior.

Description

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Performance improvement
  • Code refactoring

Testing

  • Unit tests pass
  • Integration tests pass
  • Manual testing completed

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • Any dependent changes have been merged and published

Build Artifacts

Additional Notes

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @lilfaf, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses a critical bug that caused client applications to incorrectly handle server shutdowns. By reverting the WebSocket close code for graceful server termination from '4009' back to '4200', the change ensures that clients, particularly those relying on 'pusher-js', will now correctly attempt to re-establish connections when the server goes offline temporarily, thereby preventing unintended service interruptions from the client's perspective.

Highlights

  • WebSocket Close Code Correction: Restored the WebSocket close code for graceful server shutdown from '4009' to '4200'. This change ensures that clients, especially those using 'pusher-js', correctly interpret server disconnections as temporary and attempt to auto-reconnect.
  • Client Reconnection Behavior: The previous '4009' close code incorrectly signaled clients not to reconnect, as it falls within the range for unauthorized or unrecoverable errors. The '4200' code, however, correctly indicates a server-initiated shutdown where immediate reconnection is desired, aligning with the Pusher protocol.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request correctly restores the WebSocket close code to 4200 for graceful server shutdowns, which is essential for allowing clients like pusher-js to auto-reconnect as expected. The change aligns with the Pusher protocol specification. My review includes a suggestion to improve code maintainability by defining the new close code and reason as named constants.

PR RustNSparks#139 incorrectly changed the WebSocket close code for graceful server
shutdown from 4200 to 4009, breaking pusher-js auto-reconnect behavior.

According to Pusher protocol:
- 4000-4099: Client SHOULD NOT reconnect (auth failures, unauthorized)
- 4200-4299: Client SHOULD reconnect immediately (server going away)

Code 4009 means "Connection is unauthorized" which tells clients not to
reconnect. The fix restores 4200 for server shutdown, matching Soketi's
behavior.

Note: terminate_user_connections keeps 4009 as this is for API-initiated
user termination where the app deliberately kicks users - this matches
Soketi and is correct behavior.
@lilfaf lilfaf force-pushed the fix-socket-close-code branch from 1db3cfc to 6834161 Compare December 12, 2025 17:47
@countradooku countradooku merged commit 2ca2d0e into RustNSparks:master Dec 12, 2025
3 of 4 checks passed
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