Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"Failed to load resource: net::ERR_HTTP2_PROTOCOL_ERROR" for React app after upgrading to Visual Studio 2019 16.10.0

After upgrading to VS 16.10.0 (and then 16.10.1) Community Edition a React website no longer runs w/in Visual Studio/IIS Express. The exact same code was just deployed to an Azure app service and works correctly.

The home page is blank and the following error is displayed in the Chrome (Version 91.0.4472.77 (Official Build) (64-bit)) debugger console

"Failed to load resource: net::ERR_HTTP2_PROTOCOL_ERROR"

The solution consists of:

  • C# class library (.NET Core 3.1)
  • C# Web API (.NET Core 3.1)
  • React website

I have tried the following:

  • Cleaned and rebuilt solution
  • Cleared browser cache
  • Uninstalled and re-installed Visual Studio
  • Upgraded Visual Studio from 16.10.0 to 16.10.1
  • Ran npm run build which ran with no errors

Additional Note: I was able to restore a virtual machine w/ Visual Studio 2019 v16.9.4 instead of v16.10.1. Then step by step I installed the latest Windows updates and the exact code base. The site runs correctly in v16.9.4. So the problem seems to be in Visual Studio v16.10.0/v16.10.1

Go to the VS Developer Community and up vote this problem

https://developercommunity.visualstudio.com/t/Failed-to-load-resource:-net::ERR_HTTP2_/1446262

like image 269
ChrisP Avatar asked Jun 09 '21 20:06

ChrisP


People also ask

Can a react website run in Visual Studio/IIS Express?

6 After upgrading to VS 16.10.0 (and then 16.10.1) Community Edition a React website no longer runs w/in Visual Studio/IIS Express. The exact same code was just deployed to an Azure app service and works correctly.

Why can't I upgrade to HTTP2?

If you can't upgrade try disabling HTTP/2 serverOptions.ConfigureEndpointDefaults(lo => lo.Protocols = Microsoft.AspNetCore.Server.Kestrel.Core.HttpProtocols.Http1); Mine looks like this for .net core 3.1

Why do I get err_http2_protocol_error when sending a request?

The webservers like Nginx, apache webservers will be unable to send all the responses and usually drop the request after the first chunk is sent. This would result in the content-length header not matching the actual content received and resulting in err_http2_protocol_error.

Why is HTTP/2 not working on my Machine?

The registry values disable HTTP/2 on the machine. You can remove those values when the fix to https.sys is published. Share Improve this answer Follow edited Jun 24 at 18:24


4 Answers

This error was driving me nuts too. Windows 10 was updated 2 days ago and I also updated Visual Studio to version 16.10.1. After that, I got the errors, images, CSS not loading correctly.

As SpeedOfSpin mentioned in a comment in a previous post, uninstalling KB5003637 worked instantly for me, no more errors! Everything loads perfectly now. It wasn't necessary to go back to an earlier version of Visual Studio, it seems it was Windows OS related.

@SpeedOfSpin: Thnx a lot! :)

UPDATE ON ISSUE 1 Today there was a new update KB5004476, I don't see the previous KB5003637 anymore here. KB5004476 is causing the same errors. When installed I get the exact same error "Failed to load resource: net::ERR_HTTP2_PROTOCOL_ERROR", uninstalling solves it instantly again. I have asked the Microsoft forum what is going on here: https://answers.microsoft.com/en-us/windows/forum/windows_10-networking/kb5003637-and-the-new-kb5004476-gives-error-failed/db2f2f73-7f5c-477a-b212-5f13c998a09a

UPDATE ON ISSUE 2 As they couldn't provide a solution in the first MS forum (previous link), the same question has been asked here: https://learn.microsoft.com/en-us/answers/questions/440339/kb5003637-and-the-new-kb5004476-gives-error-34fail.html Updating Visual Studio to version 16.10.2. doesn't solve the issue either.

UPDATE ON ISSUE 3 After some more testing, it seems it affects the browser Chrome only (As I only use Chrome, as most people do). In Firefox, Edge, and IE it seems I'm not having this issue. It was confusing as I tried so many things and the only solution I still have is uninstalling the KB5003637 or the new version KB5004476. So I guess something is wrong with Chrome after all. For now, I will keep the updates uninstalled, I don't feel like changing my preferred browser.

UPDATE ON ISSUE 4 It is indeed not a Chrome-only issue, sorry guys. Saw the same error in Edge this morning too. It took a long while to recreate the problem, while in Chrome I have it every single time. :(

UPDATE ON ISSUE 5 As asked in the first post here by ChrisP, go to the VS Developer Community if you experience this issue too, and please upvote this problem. I asked the question there also, but still no solid solution at this point.

https://developercommunity.visualstudio.com/t/Failed-to-load-resource:-net::ERR_HTTP2_/1446262

UPDATE ON ISSUE 6 Two days ago after 1 single refresh (F5), when testing my web application, aside from the HTTP/2 errors, I also had the same blue screen like people are starting to mention. It showed the error "System Thread Exception not Handled" in file "HTTP.sys" and restarted, amazing!

enter image description here

Also, 2 new updates were installed KB5003690 and KB5003537, but nothing changed, I still have the annoying errors. Previous updates KB5003637 and KB5004476, where it started to go wrong, are gone here.

Uninstalling these updates as a workaround isn't the best solution for me, as they get reinstalled when wanting to update Windows 10 (No option anymore to exclude/hide the updates).

For me the easiest/quickest workaround at this point, to test locally with no “Failed to load resource: net::ERR_HTTP2_PROTOCOL_ERROR” errors, no "System Thread Exception not Handled" BSoD! error and most important no stress anymore :), is disabling SSL in the debug settings of your project in Visual Studio. (Right-click Project, Properties, Debug, Web Server Settings below).

Hope this gets fixed quickly!

UPDATE ON ISSUE 7 (SOLVED!) Microsoft finally released a fix that works for me, more information here (last post): https://developercommunity.visualstudio.com/t/Failed-to-load-resource:-net::ERR_HTTP2_/1446262?viewtype=all

Installing the most recent update KB5004237 solves the problem in my case. No more "Failed to load resource: net::ERR_HTTP2_PROTOCOL_ERROR" errors, no more “System Thread Exception not Handled” error so far too!

like image 182
Lester DM Avatar answered Oct 10 '22 18:10

Lester DM


I tried everything including rolling back updates and a full reinstall of Windows. Finally, a Microsoft support rep posted a workaround for this that involves disabling HTTP2. This seems to have worked for me as a temporary solution. In summary:

  1. Start the Windows Registry Editor
  2. Navigate to the registry key HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\HTTP\Parameters
  3. Add 2 new REG_DWORD values, EnableHttp2Tls and EnableHttp2Cleartext, to this registry key
  4. Set both values to 0
  5. Reboot the machine

The rep notes:

The registry values disable HTTP/2 on the machine. You can remove those values when the fix to https.sys is published.

like image 26
kkarpack Avatar answered Oct 10 '22 17:10

kkarpack


We had the same issue on only the machines that had that KB5003637 installed. We uninstalled it and everything was fine. We decided to upgrade to .net 5 in the end which fixes the issue as it was fairly painless for our projects.

If you can't upgrade try disabling HTTP/2

serverOptions.ConfigureEndpointDefaults(lo => lo.Protocols = Microsoft.AspNetCore.Server.Kestrel.Core.HttpProtocols.Http1);

Mine looks like this for .net core 3.1

public static IHostBuilder CreateWebHostBuilder(string[] args) =>
            Host.CreateDefaultBuilder(args)
                .ConfigureWebHostDefaults(webBuilder =>
                {
                    webBuilder.ConfigureKestrel(serverOptions =>
                    {
                        serverOptions.Limits.MaxRequestBodySize = int.MaxValue;
                        serverOptions.Limits.MinResponseDataRate = null;
                        serverOptions.ConfigureEndpointDefaults(lo => lo.Protocols = Microsoft.AspNetCore.Server.Kestrel.Core.HttpProtocols.Http1);
                    })
                    .UseStartup<Startup>();
                });
        }
like image 2
SpeedOfSpin Avatar answered Oct 10 '22 18:10

SpeedOfSpin


Disable the SSL from the project properties it will automatically down to http/1 and then enable the javascript debugger for the browser

Hope this will help

like image 1
Wani Mudasir Avatar answered Oct 10 '22 18:10

Wani Mudasir