HTTP/2 connection error (PROTOCOL_ERROR): Invalid HTTP/2 connection preface
See original GitHub issueChange the server configuration of the sample to Kestrel, and then connect aspnetcore grpc-web through Http protocol , The following error occurred:
dbug: Microsoft.AspNetCore.Server.Kestrel[29]
Connection id "0HLTV45E8MTR4": HTTP/2 connection error.
Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http2.Http2ConnectionErrorException: HTTP/2 connection error (PROTOCOL_ERROR): Invalid HTTP/2 connection preface.
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http2.Http2Connection.ParsePreface(ReadOnlySequence`1& buffer, SequencePosition& consumed, SequencePosition& examined)
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http2.Http2Connection.TryReadPrefaceAsync()
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http2.Http2Connection.ProcessRequestsAsync[TContext](IHttpApplication`1 application)
But using iisexpress to start the service, and the client connects through the http protocol, it works fine
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http2. ...
Http2.Http2ConnectionErrorException: HTTP/2 connection error (PROTOCOL_ERROR): Invalid HTTP/2 connection preface. I will describe my conditions.
Read more >RFC 7540 - Hypertext Transfer Protocol Version 2 (HTTP/2)
Clients and servers MUST treat an invalid connection preface as a connection error (Section 5.4.1) of type PROTOCOL_ERROR. A GOAWAY frame (Section 6.8)...
Read more >Re: Invalid HTTP2 preface handling?
I'm wondering what would be the problem if on an invalid preface, the > server check if it is actually a valid HTTP/1...
Read more >Getting 'Invalid HTTP/2 preamble' when 'DISABLE_SSL: true'
I have my jetconf server working fine with 'DISABLE_SSL: false' When I try to use jetconf with http instead of https, it fails...
Read more >gRPC – What I Broke
Internal.Http2.Http2ConnectionErrorException: HTTP/2 connection error (PROTOCOL_ERROR): Invalid HTTP/2 connection preface. at Microsoft.AspNetCore.Server.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This is failing because you are trying to call a HTTP/2 only port without TLS (HTTPS). That isn’t supported by browsers. You either need to use TLS, or change protocols to
Microsoft.AspNetCore.Server.Kestrel.Core.HttpProtocols.Http1AndHttp2
(although it will always use HTTP/1.1 because TLS is not available)I removed all Kestrel related configuration in appsetting, and this is my Program.cs
If you start debugging in visual studio in console , do not use IIS EXPRESS , then use javascript grpc-web client to connect it through the http protocol , you will see this error if you set “Microsoft.AspNetCore.Server.Kestrel”: “Debug”
When you set config.UseHttps() , the javascript client will connect success through the https protocol