[PR #11395] [MERGED] Fix WebSocket disconnecting when exception is thrown during processing #12698

Closed
opened 2025-12-22 09:26:46 +01:00 by backuprepo · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/jellyfin/jellyfin/pull/11395
Author: @nielsvanvelzen
Created: 4/21/2024
Status: Merged
Merged: 4/21/2024
Merged by: @crobibero

Base: masterHead: ws-fix


📝 Commits (1)

  • 2f65d8e Fix WebSocket disconnecting when exception is thrown during processing

📊 Changes

1 file changed (+14 additions, -7 deletions)

View changed files

📝 Emby.Server.Implementations/HttpServer/WebSocketConnection.cs (+14 -7)

📄 Description

A WebSocket connection should not (forcefully) be closed when an incoming message fails to process. In the specific issue I encountered it was due to new authorization requirements, which we should just NO-OP to.

[2024-04-21 14:53:52.405 +02:00] [INF] [113] Emby.Server.Implementations.HttpServer.WebSocketManager: WS "192.168.1.1" request
[2024-04-21 14:53:52.417 +02:00] [ERR] [46] Emby.Server.Implementations.HttpServer.WebSocketManager: WS "192.168.1.1" WebSocketRequestHandler error
MediaBrowser.Controller.Authentication.AuthenticationException: Only admin users can subscribe to session information.
   at Jellyfin.Api.WebSocketListeners.SessionInfoWebSocketListener.Start(WebSocketMessageInfo message) in jellyfin\Jellyfin.Api\WebSocketListeners\SessionInfoWebSocketListener.cs:line 84
   at Emby.Server.Implementations.HttpServer.WebSocketManager.ProcessWebSocketMessageReceived(WebSocketMessageInfo result) in jellyfin\Emby.Server.Implementations\HttpServer\WebSocketManager.cs:line 92
   at Emby.Server.Implementations.HttpServer.WebSocketConnection.ProcessInternal(PipeReader reader)
   at Emby.Server.Implementations.HttpServer.WebSocketConnection.ReceiveAsync(CancellationToken cancellationToken) in jellyfin\Emby.Server.Implementations\HttpServer\WebSocketConnection.cs:line 140
   at Emby.Server.Implementations.HttpServer.WebSocketManager.WebSocketRequestHandler(HttpContext context) in jellyfin\Emby.Server.Implementations\HttpServer\WebSocketManager.cs:line 69
   at Emby.Server.Implementations.HttpServer.WebSocketManager.WebSocketRequestHandler(HttpContext context) in jellyfin\Emby.Server.Implementations\HttpServer\WebSocketManager.cs:line 70

Changes

  • Add try-catch to avoid WS from closing due to uncaught exception

Issues

Regression from #9875


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/jellyfin/jellyfin/pull/11395 **Author:** [@nielsvanvelzen](https://github.com/nielsvanvelzen) **Created:** 4/21/2024 **Status:** ✅ Merged **Merged:** 4/21/2024 **Merged by:** [@crobibero](https://github.com/crobibero) **Base:** `master` ← **Head:** `ws-fix` --- ### 📝 Commits (1) - [`2f65d8e`](https://github.com/jellyfin/jellyfin/commit/2f65d8e276f3609e2863b7aa0611facf87942e35) Fix WebSocket disconnecting when exception is thrown during processing ### 📊 Changes **1 file changed** (+14 additions, -7 deletions) <details> <summary>View changed files</summary> 📝 `Emby.Server.Implementations/HttpServer/WebSocketConnection.cs` (+14 -7) </details> ### 📄 Description A WebSocket connection should not (forcefully) be closed when an incoming message fails to process. In the specific issue I encountered it was due to new authorization requirements, which we should just NO-OP to. ``` [2024-04-21 14:53:52.405 +02:00] [INF] [113] Emby.Server.Implementations.HttpServer.WebSocketManager: WS "192.168.1.1" request [2024-04-21 14:53:52.417 +02:00] [ERR] [46] Emby.Server.Implementations.HttpServer.WebSocketManager: WS "192.168.1.1" WebSocketRequestHandler error MediaBrowser.Controller.Authentication.AuthenticationException: Only admin users can subscribe to session information. at Jellyfin.Api.WebSocketListeners.SessionInfoWebSocketListener.Start(WebSocketMessageInfo message) in jellyfin\Jellyfin.Api\WebSocketListeners\SessionInfoWebSocketListener.cs:line 84 at Emby.Server.Implementations.HttpServer.WebSocketManager.ProcessWebSocketMessageReceived(WebSocketMessageInfo result) in jellyfin\Emby.Server.Implementations\HttpServer\WebSocketManager.cs:line 92 at Emby.Server.Implementations.HttpServer.WebSocketConnection.ProcessInternal(PipeReader reader) at Emby.Server.Implementations.HttpServer.WebSocketConnection.ReceiveAsync(CancellationToken cancellationToken) in jellyfin\Emby.Server.Implementations\HttpServer\WebSocketConnection.cs:line 140 at Emby.Server.Implementations.HttpServer.WebSocketManager.WebSocketRequestHandler(HttpContext context) in jellyfin\Emby.Server.Implementations\HttpServer\WebSocketManager.cs:line 69 at Emby.Server.Implementations.HttpServer.WebSocketManager.WebSocketRequestHandler(HttpContext context) in jellyfin\Emby.Server.Implementations\HttpServer\WebSocketManager.cs:line 70 ``` **Changes** - Add try-catch to avoid WS from closing due to uncaught exception **Issues** Regression from #9875 --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
backuprepo 2025-12-22 09:26:46 +01:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: starred/jellyfin#12698
No description provided.