This is my setup:
Error = "HTTP/2 over TLS was not negotiated on an HTTP/2-only endpoint."
So... Someone else implemented this Grpc Server (E). I can call this one with both applications. No errors.
But to get a nice development environment for developing the two applications, I got the proto-file from the production server and developed my own implementation (D). I use this for testing error handling in the clients - I can control which responses the server gives.
I implemented two exactly alike unit tests, which are in fact integration tests. One in a .net framework project and one in a .net core project.
And it works for .net core test, but not the .net framework.
However, if I inject a WinHttpHandler
instead of the HttpClientHandler
, then it works. I really do not want to have to inject a handler (it's not even an interface).
Also the production gRPC server works, as mentioned before. But I do not know why mine fails and the production gRPC server works.
I think somehow my own implementation of the gRPC service is wrong (or lacking) but I do not know what I am missing.
Please help!
Grpc.Net.Client only works on .NET Framework (as opposed to .NET Core and .NET5+) with limitations. The reason is that .NET Framework doesn't really have a HTTP/2 implementation, which is a requirement for gRPC protocol (but not for grpc-web, it that's an option for you).
Grpc.Net.Client works on .NET Framework to some extent with WinHttpHandler (as you've discovered). The limitations are documented here:
Actually, I had this in my appsetting.json (which I had copied from another project):
"Kestrel": {
"EndpointDefaults": {
"Protocols": "Http2"
}
Of cause, deleting that from the file solved my problem.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.