-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Preview: Replaces WebSocket with the SignalR library to improve connectivity in the preview window #20585
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…e preview context
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR migrates the preview live update mechanism from a custom WebSocket implementation to the SignalR library, improving connection reliability and adding user-friendly error notifications. The change simplifies the connection logic by leveraging SignalR's built-in protocol handling and connection lifecycle management.
Key Changes:
- Replaced manual WebSocket with SignalR
HubConnectionfor preview updates - Added localized notification messages for connection failures and disconnections
- Moved connection initialization from
iframeLoadedto constructor to ensure single connection
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
src/Umbraco.Web.UI.Client/src/apps/preview/preview.context.ts |
Replaces WebSocket with SignalR HubConnection, adds notification context and localization controller, moves connection initialization to constructor |
src/Umbraco.Web.UI.Client/src/assets/lang/en.ts |
Adds English localization strings for connection failure and connection lost messages |
src/Umbraco.Web.UI.Client/src/assets/lang/da.ts |
Adds Danish localization strings for connection errors and fixes placement of existing translation key |
Test DirectionsPrerequisites
Basic Preview Functionality TestingTest 1: Preview Live Updates (Single Instance)
Test 2: SignalR Connection Notifications
Test 3: Multiple Preview Windows
Load Balancing Compatibility Testing (Optional but Important)This PR enables SignalR backplane compatibility for load-balanced environments. To test: Prerequisites:
Setup:
In private static readonly string[] _knownHosts =
[
"https://localhost:44339",
"https://localhost:44340",
// ... existing hosts
];
using Umbraco.Cms.Core.Composing;
namespace Umbraco.Cms.Web.UI.SignalRLoadBalancing;
public class SignalRComposer : IComposer
{
public void Compose(IUmbracoBuilder builder)
{
var connectionString = "Server=127.0.0.1,1433;Database=SignalRBackplane;User ID=sa;Password=YourPassword123;TrustServerCertificate=True;Encrypt=False;";
builder.Services.AddSignalR().AddSqlServer(connectionString);
// Enable load balanced isolated cache synchronization
builder.LoadBalanceIsolatedCaches();
}
}Test 4: Cross-Instance Preview Updates
Key Improvement: This PR enables the preview feature to work correctly with SignalR backplanes in load-balanced environments, which was not possible with the previous custom WebSocket implementation. Regression TestingTest 5: Preview with Unpublished Changes
Test 6: Browser Console Checks
|
leekelleher
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested out in a peer review, works as expected in a load balanced set-up. 🚀
This pull request migrates the preview live update mechanism from a custom WebSocket implementation to SignalR, improving stability and user feedback. It also adds localized notification messages for connection issues. The most significant changes are grouped below.
Benefits:
Migration to SignalR for Preview Live Updates:
UmbPreviewContextwith a SignalRHubConnection, usingHubConnectionBuilderto connect to the/umbraco/PreviewHubendpoint and listen for 'refreshed' events. The connection is now started and stopped using SignalR methods, and event handlers provide better connection lifecycle management. [1] [2] [3] [4] [5]User Notifications and Localization:
connectionFailed,connectionLost) in both Danish (da.ts) and English (en.ts) language files. [1] [2]Minor Improvements:
iframeLoadedevent to the constructor)