Skip to content
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

angular 11 throws net::ERR_SSL_PROTOCOL_ERROR #19403

Closed
snebjorn opened this issue Nov 16, 2020 · 11 comments · Fixed by #19412
Closed

angular 11 throws net::ERR_SSL_PROTOCOL_ERROR #19403

snebjorn opened this issue Nov 16, 2020 · 11 comments · Fixed by #19412

Comments

@snebjorn
Copy link

🐞 bug report

Affected Package

The issue is caused by package @angular/cli or @angular/core

Is this a regression?

Yes, the previous version in which this bug was not present was: 10.2.3

Console output in Angular 11:

image

image

Description

It was working in Angular 10.

Console output:

image

image

🔬 Minimal Reproduction

Clone https://github.com/snebjorn/dotnet-angular11

  1. Run ng serve in ClientApp folder
  2. Run dotnet run in the root folder
  3. Open the browser at https://localhost:5001/
  4. Observe the errors

🌍 Your Environment

Angular Version:


Angular CLI: 11.0.1
Node: 12.16.1
OS: win32 x64

Angular: 11.0.0
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router
Ivy Workspace: Yes

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1001.2
@angular-devkit/build-angular   0.1100.1
@angular-devkit/core            10.1.2
@angular-devkit/schematics      11.0.1
@angular/cli                    11.0.1
@schematics/angular             11.0.1
@schematics/update              0.1100.1
rxjs                            6.6.3
typescript                      4.0.5

Anything else relevant?

The frontend is accessed via https://localhost:5001 because it's "hosted" with ASP.NET Core using spa.UseProxyToSpaDevelopmentServer("http://localhost:4200");. See https://docs.microsoft.com/en-us/aspnet/core/client-side/spa/angular?view=aspnetcore-5.0&tabs=visual-studio

The self-signed localhost certificate is trusted. dotnet dev-certs https -t. See https://docs.microsoft.com/en-us/aspnet/core/security/enforcing-ssl?view=aspnetcore-5.0&tabs=visual-studio#trust-the-aspnet-core-https-development-certificate-on-windows-and-macos

@atscott
Copy link
Contributor

atscott commented Nov 16, 2020

@alan-agius4 - Is this a CLI issue? I saw in the discord channel a mention about something similar, "ng serve --host 0.0.0.0 --public-host http://localhost worked to get the development websocket talking through a reverse proxy setup."

@alan-agius4
Copy link
Collaborator

@atscott, yeah I’ll take a look at it.

@alan-agius4 alan-agius4 transferred this issue from angular/angular Nov 16, 2020
@alan-agius4
Copy link
Collaborator

alan-agius4 commented Nov 16, 2020

@snebjorn, can you try to set the publicHost option under dev-server to https://localhost:5001?

@prabh-62
Copy link

Alan, adding publicHost option doesn't help. Scheme should be http not https

logs_ws

@alan-agius4 alan-agius4 self-assigned this Nov 16, 2020
@alan-agius4
Copy link
Collaborator

Let me get back to you in this tomorrow.

@snebjorn
Copy link
Author

I stumpled upon this dotnet/aspnetcore#27790 seems relevant :)

@jr01
Copy link

jr01 commented Nov 16, 2020

I experience the same issue, but the workaround ng serve --publicHost=localhost:44300 does work for me.

My setup

  • ng serve with all default settings.
  • asp.net core SPA services proxy builder.UseProxyToSpaDevelopmentServer("http://localhost:4200"); and asp.net Kestrel server runs on https://localhost:44300

In Angular 10 when navigating to https://localhost:44300 Angular makes a call to https://localhost:44300/sockjs-node/.... and live reload works.

In Angular 11 when navigating to https://localhost:44300 Angular makes a call to http://localhost:4200/sockjs-node/.... which gets blocked by the browser (CSP).

In Angular 11 vendor.js I notice:

socket(socketUrl, onSocketMessage);
/* WEBPACK VAR INJECTION */}.call(this, "?http://localhost:4200&sockPath=/sockjs-node"))

As mentioned with ng serve --publicHost=localhost:44300 live reload works in Angular 11 and the vendor.js contains
.../* WEBPACK VAR INJECTION */}.call(this, "?http://localhost:44300&sockPath=/sockjs-node"))

@erictor
Copy link

erictor commented Nov 17, 2020

The ERR_SSL issue described here gets resolved now with Angular 11.1 / Angular CLI 11.2. However for me it did not resolve the other issue I've been experiencing which is that Live Reload is still getting killed because the error:

sockjs.js:2999 WebSocket connection to 'wss://localhost:44300/sockjs-node/.../websocket' failed: WebSocket is closed before the connection is established

occurs for me nearly every time the browser reloads.

@prabh-62
Copy link

I created #19406 as a separate issue since there could be a different issue with dotnet AspNetCore template and I don't want to hijack this thread

@alan-agius4
Copy link
Collaborator

alan-agius4 commented Nov 17, 2020

Hi all,

Thanks all for the input and all the users who provided the reproductions. I diid look at both reproductions this morning (https://github.com/prabh-62/angular-reverse-proxy and https://github.com/snebjorn/dotnet-angular11)

I will be creating a PR with a fix for this shortly. As a workaround you can use --public-host=0.0.0.0:0

Thanks.

@ngbot ngbot bot added this to the needsTriage milestone Nov 17, 2020
clydin pushed a commit that referenced this issue Nov 17, 2020
… HTTPS reverse proxy

With this change we set the publicHost to `0.0.0.0:0`, when it's not provided.

This solved issues where previously the publicHost needed to be specified directly to get around `ERR_SSL_PROTOCOL_ERROR` error when proxing https -> http.

NB: this was also the behaviour in version 10 https://github.com/angular/angular-cli/blob/c252968225c0ecac6c4d8ee08e14ae64de8791a8/packages/angular_devkit/build_angular/src/dev-server/index.ts#L170

Closes #19403
clydin pushed a commit that referenced this issue Nov 17, 2020
… HTTPS reverse proxy

With this change we set the publicHost to `0.0.0.0:0`, when it's not provided.

This solved issues where previously the publicHost needed to be specified directly to get around `ERR_SSL_PROTOCOL_ERROR` error when proxing https -> http.

NB: this was also the behaviour in version 10 https://github.com/angular/angular-cli/blob/c252968225c0ecac6c4d8ee08e14ae64de8791a8/packages/angular_devkit/build_angular/src/dev-server/index.ts#L170

Closes #19403

(cherry picked from commit f67c612)
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Dec 20, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.