Skip to content

Commit f57c9e9

Browse files
[main] Revert Enforce WebSockets Transport for Blazor (#36674)
* Revert Enforce WebSockets Transport for Blazor * Updated Release JS Files Co-authored-by: Tanay Parikh <[email protected]>
1 parent ba02425 commit f57c9e9

File tree

9 files changed

+8
-277
lines changed

9 files changed

+8
-277
lines changed

src/Components/Server/src/Builder/ComponentEndpointRouteBuilderExtensions.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,7 @@ public static ComponentEndpointConventionBuilder MapBlazorHub(
5252
throw new ArgumentNullException(nameof(path));
5353
}
5454

55-
// Only support the WebSockets transport type by default
56-
return endpoints.MapBlazorHub(path, configureOptions: options => { options.Transports = HttpTransportType.WebSockets; });
55+
return endpoints.MapBlazorHub(path, configureOptions: _ => { });
5756
}
5857

5958
/// <summary>

src/Components/Web.JS/dist/Release/blazor.server.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Components/Web.JS/dist/Release/blazor.webview.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Components/Web.JS/src/Boot.Server.ts

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { DotNet } from '@microsoft/dotnet-js-interop';
22
import { Blazor } from './GlobalExports';
3-
import { HubConnectionBuilder, HubConnection, HttpTransportType } from '@microsoft/signalr';
3+
import { HubConnectionBuilder, HubConnection } from '@microsoft/signalr';
44
import { MessagePackHubProtocol } from '@microsoft/signalr-protocol-msgpack';
55
import { showErrorNotification } from './BootErrors';
66
import { shouldAutoStart } from './BootCommon';
@@ -86,7 +86,7 @@ async function initializeConnection(options: CircuitStartOptions, logger: Logger
8686
(hubProtocol as unknown as { name: string }).name = 'blazorpack';
8787

8888
const connectionBuilder = new HubConnectionBuilder()
89-
.withUrl('_blazor', HttpTransportType.WebSockets)
89+
.withUrl('_blazor')
9090
.withHubProtocol(hubProtocol);
9191

9292
options.configureSignalR(connectionBuilder);
@@ -144,14 +144,7 @@ async function initializeConnection(options: CircuitStartOptions, logger: Logger
144144
// Throw this exception so it can be handled at the reconnection layer, and don't show the
145145
// error notification.
146146
throw ex;
147-
} else if (!isNestedError(ex)) {
148-
showErrorNotification();
149-
} else if (ex.innerErrors && ex.innerErrors.some(e => e.errorType === 'UnsupportedTransportError' && e.transport === HttpTransportType.WebSockets)) {
150-
showErrorNotification('Unable to connect, please ensure you are using an updated browser that supports WebSockets.');
151-
} else if (ex.innerErrors && ex.innerErrors.some(e => e.errorType === 'FailedToStartTransportError' && e.transport === HttpTransportType.WebSockets)) {
152-
showErrorNotification('Unable to connect, please ensure WebSockets are available. A VPN or proxy may be blocking the connection.');
153-
} else if (ex.innerErrors && ex.innerErrors.some(e => e.errorType === 'DisabledTransportError' && e.transport === HttpTransportType.LongPolling)) {
154-
logger.log(LogLevel.Error, 'Unable to initiate a SignalR connection to the server. This might be because the server is not configured to support WebSockets. To troubleshoot this, visit https://aka.ms/blazor-server-websockets-error.');
147+
} else {
155148
showErrorNotification();
156149
}
157150
}
@@ -169,14 +162,8 @@ async function initializeConnection(options: CircuitStartOptions, logger: Logger
169162
});
170163

171164
return connection;
172-
173-
function isNestedError(error: any): error is AggregateError {
174-
return error && ('innerErrors' in error);
175-
}
176165
}
177166

178-
type AggregateError = Error & { innerErrors: { errorType: string, transport: HttpTransportType }[] };
179-
180167
function unhandledError(connection: HubConnection, err: Error, logger: Logger): void {
181168
logger.log(LogLevel.Error, err);
182169

src/Components/Web.JS/src/BootErrors.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
11
let hasFailed = false;
22

3-
export async function showErrorNotification(customErrorMessage: string = '') {
3+
export async function showErrorNotification() {
44
let errorUi = document.querySelector('#blazor-error-ui') as HTMLElement;
55
if (errorUi) {
66
errorUi.style.display = 'block';
7-
8-
if (customErrorMessage && errorUi.firstChild) {
9-
errorUi.firstChild.textContent = `\n\t${customErrorMessage}\t\n`;
10-
}
117
}
128

139
if (!hasFailed) {

src/Components/test/E2ETest/ServerExecutionTests/ServerTransportsTest.cs

Lines changed: 0 additions & 124 deletions
This file was deleted.

src/Components/test/testassets/TestServer/Pages/Transports.cshtml

Lines changed: 0 additions & 69 deletions
This file was deleted.

src/Components/test/testassets/TestServer/ServerStartup.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public void ConfigureServices(IServiceCollection services)
4242
}
4343

4444
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
45-
public virtual void Configure(IApplicationBuilder app, IWebHostEnvironment env, ResourceRequestLog resourceRequestLog)
45+
public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ResourceRequestLog resourceRequestLog)
4646
{
4747
var enUs = new CultureInfo("en-US");
4848
CultureInfo.DefaultThreadCurrentCulture = enUs;

src/Components/test/testassets/TestServer/TransportsServerStartup.cs

Lines changed: 0 additions & 58 deletions
This file was deleted.

0 commit comments

Comments
 (0)