This article is a mirror article of machine translation, please click here to jump to the original article.

View: 54622|Reply: 0

[Source] .NET Core calls gRPC HTTP (non-TLS protected) address error solutions

[Copy link]
Posted on 2021-3-22 16:45:16 | | | |
gRPC is a high-performance remote procedure call (RPC) framework that is language agnostic.

The main benefits of gRPC are:

Modern, high-performance, lightweight RPC framework.
Contract-first API development that uses protocol buffers by default, allowing for language-agnostic implementations.
Tools available in multiple languages to generate strongly typed servers and clients.
Supports client, server, and two-way streaming calls.
Reduce the use of the network with Protobuf binary serialization.

These benefits make gRPC suitable for:

Lightweight microservices where efficiency is critical.
Polyglot systems that require multiple languages for development.
Peer-to-peer real-time services that need to handle streaming requests or responses.

Review:
Practical combat: ASP.NET Core uses gRPC communication
https://www.itsvse.com/thread-8834-1-1.html

.net/c# Google Protocol Buffers Quick Start
https://www.itsvse.com/thread-3626-1-1.html

.net/c# Google Protocol Buffers tutorial
https://www.itsvse.com/thread-3668-1-1.html

When using ASP.NET Core 3.1, a gRPC service is enabled, and the HTTP/2 endpoint is configured without TLS protection, see:The hyperlink login is visible.

Using the .NET Core 3.1 console, I tried to call the HTTP gRPC service address with the following error:


Unhandled exception. Grpc.Core.RpcException: Status(StatusCode="Unavailable", Detail="Error starting gRPC call. HttpRequestException: An error occurred while sending the request. IOException: The response ended prematurely.", DebugException="System.Net.Http.HttpRequestException: An error occurred while sending the request.
---> System.IO.IOException: The response ended prematurely.



Depending on the version of .NET your app uses, there are some additional requirements to call an insecure gRPC service:

.NET 5 or later requires Grpc.Net.Client version 2.32.0 or later.
.NET Core 3.x requires additional configuration. The app must set the System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport switch to true:


The client settings are as follows:

Only .NET Core 3.x requires the System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport switch. No additional configuration is required in .NET 5, nor is this requirement


The hyperlink login is visible.





Previous:.NET/C# Reflection, Emit, Expression performance testing
Next:Late newcomer reports
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com