JavaScriptServices icon indicating copy to clipboard operation
JavaScriptServices copied to clipboard

Hot swap stops working when you enable HTTPS

Open glangdonvt opened this issue 10 years ago • 13 comments

Troubleshooting development mode Your project worked like a dream. then I try to modify it to run in HTTPS--first editing the product properties to be HTTPS in Visual Studio, using the recommended https: port number.

Eventually I found this https://github.com/aspnet/Home/issues/1486, added the right extra references into the Startup.cs file, and now I can run https: at whatever port I want, but the hot swap recompilation stopped working.

I recreated the project from scratch. As soon as I uncomment the two commented lines below (Startup.cs), web site works fine, but hot module swap stops functioning. .UseKestrel(options => { var serverCertificate = LoadCertificate(); //options.UseHttps(serverCertificate); })

            //.UseUrls("https://localhost:5001")

glangdonvt avatar Aug 19 '16 01:08 glangdonvt

HotModuleReplacement is being ran in http, and you have .net on https. You need to run webpack-Dev-server with --https, but I'm not sure if aspnet-webpack is setup to currently handle that situation. Steve would know best!

MarkPieszak avatar Aug 19 '16 03:08 MarkPieszak

Thanks, Mark. This code is using the AspNetCore's UseWebpackDevMiddleware. When you look at the source code for it, line 17 hard-codes that to http. Seems like that may be my issue. Please let me know if you think I should look elsewhere. Otherwise, I'll submit this issue to that team.

13 namespace Microsoft.AspNetCore.Builder 14 { 15 public static class WebpackDevMiddleware 16 { 17 private const string WebpackDevMiddlewareScheme = "http"; 18 private const string WebpackHotMiddlewareEndpoint = "/__webpack_hmr"; 19 private const string DefaultConfigFile = "webpack.config.js";

glangdonvt avatar Aug 19 '16 11:08 glangdonvt

Ahh nice catch, didn't have a chance to look last night. Yes it looks like we need to add a new option to WebpackDevMiddlewareOptions for https. Let me give it a test run and see if I can get it all working before putting in a fix.

MarkPieszak avatar Aug 19 '16 14:08 MarkPieszak

Should be all set with PR #272

MarkPieszak avatar Aug 19 '16 14:08 MarkPieszak

Thanks, Mark, I’ll try it out over the weekend. George

From: Mark Pieszak [mailto:[email protected]] Sent: Friday, August 19, 2016 10:31 AM To: aspnet/JavaScriptServices [email protected] Cc: George Langdon [email protected]; Author [email protected] Subject: Re: [aspnet/JavaScriptServices] Hot swap stops working when you enable HTTPS (#271)

Should be all set with PR #272https://github.com/aspnet/JavaScriptServices/pull/272

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/aspnet/JavaScriptServices/issues/271#issuecomment-241034304, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AORU4ykSlPZrAWsMKGzl_RN_Rr_UiHzjks5qhb4xgaJpZM4JoDpu.

glangdonvt avatar Aug 19 '16 15:08 glangdonvt

This is now fixed. Now, the HMR integration handles /__webpack_hmr requests by reverse-proxying them, instead of 302-redirecting, to the underlying Node service. That means it's independent of what scheme/hostname/etc the browser is connecting on, because the browser never sees the Node HMR service directly any more.

To get this fix, upgrade to a newer version of Microsoft.AspNetCore.SpaServices. However I haven't yet published this update to NuGet - will do so shortly.

SteveSandersonMS avatar Sep 09 '16 16:09 SteveSandersonMS

Update: The newer Microsoft.AspNetCore.SpaServices (and related packages) is now published to NuGet

SteveSandersonMS avatar Sep 09 '16 16:09 SteveSandersonMS

Thanks! NOW I'll try it over the weekend.

glangdonvt avatar Sep 09 '16 16:09 glangdonvt

Unfortunately I've had to revert the change that fixed this, because of issues with long-running requests triggering ECANCELED/EPIPE broken pipe errors.

I've submitted a repro to the Kestrel repo and will hopefully put in a better event-stream proxying implementation here once they let me know what (if anything) is the supported way to do this.

SteveSandersonMS avatar Sep 13 '16 11:09 SteveSandersonMS

Thanks for the heads up.

glangdonvt avatar Sep 13 '16 12:09 glangdonvt

Any progress considering this issue?

boban100janovski avatar Oct 20 '16 21:10 boban100janovski

It looks like core 1.1 will have part of the fix in it when it comes out (if I understood the kestrel thread right). @boban984

MarkPieszak avatar Oct 20 '16 22:10 MarkPieszak

Thanks!

From: Steve Sanderson [mailto:[email protected]] Sent: Wednesday, November 30, 2016 11:56 AM To: aspnet/JavaScriptServices [email protected] Cc: George Langdon [email protected]; Author [email protected] Subject: Re: [aspnet/JavaScriptServices] Hot swap stops working when you enable HTTPS (#271)

Closed #271https://github.com/aspnet/JavaScriptServices/issues/271 via e2f8031https://github.com/aspnet/JavaScriptServices/commit/e2f8031bb8e807f713733d6a641a84b895bfdfcb.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/aspnet/JavaScriptServices/issues/271#event-877167410, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AORU4--KCs21QEFbDIEZ3EGUOJdrRYpXks5rDaq6gaJpZM4JoDpu.

glangdonvt avatar Nov 30 '16 20:11 glangdonvt