From 683416143da7c49bb29b0ef147760eb0e6200e0a Mon Sep 17 00:00:00 2001 From: Louis Larpin Date: Fri, 12 Dec 2025 18:36:43 +0100 Subject: [PATCH] fix: restore close code 4200 for graceful shutdown 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. --- src/main.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index 969e8fc8..246b4002 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1311,8 +1311,7 @@ impl SockudoServer { .map(|(_app_id, ws_raw_obj)| { async move { let mut ws = ws_raw_obj.inner.lock().await; // Lock the WebSocketRef - if let Err(e) = - ws.close(4009, "User terminated by app.".to_string()).await + if let Err(e) = ws.close(4200, "Server shutting down".to_string()).await { error!("Failed to close WebSocket: {:?}", e); }