gRPC with HTTP endpoint
Just following the tutorials of documents, and it looks like gRPC can call with insecure endpoints, e.g., without HTTPS.
Call insecure gRPC services with .NET Core client
I am using latest .NET 6, creating ASP.NET Core as gRPC server and .NET core Console as gRPC client. However it throws exception. Do I need to make other changes to support this? Like Kestrel protocol or something?
RpcException: Status(StatusCode="Unavailable", Detail="Error starting gRPC call. HttpRequestException: An error occurred while sending the request. IOException: The request was aborted. Http2ConnectionException: The HTTP/2 server sent invalid data on the connection. HTTP/2 error code 'PROTOCOL_ERROR' (0x1).", DebugException="System.Net.Http.HttpRequestException: An error occurred while sending the request.
---> System.IO.IOException: The request was aborted.
---> System.Net.Http.Http2ConnectionException: The HTTP/2 server sent invalid data on the connection. HTTP/2 error code 'PROTOCOL_ERROR' (0x1).
at System.Net.Http.Http2Connection.ThrowProtocolError(Http2ProtocolErrorCode errorCode)
at System.Net.Http.Http2Connection.ReadFrameAsync(Boolean initialFrame)
at System.Net.Http.Http2Connection.ProcessIncomingFramesAsync()
--- End of inner exception stack trace ---
at System.Net.Http.Http2Connection.ThrowRequestAborted(Exception innerException)
at System.Net.Http.Http2Connection.Http2Stream.CheckResponseBodyState()
at System.Net.Http.Http2Connection.Http2Stream.TryEnsureHeaders()
at System.Net.Http.Http2Connection.Http2Stream.ReadResponseHeadersAsync(CancellationToken cancellationToken)
at System.Net.Http.Http2Connection.SendAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
--- End of inner exception stack trace ---
at System.Net.Http.Http2Connection.SendAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
at System.Net.Http.HttpConnectionPool.SendWithVersionDetectionAndRetryAsync(HttpRequestMessage request, Boolean async, Boolean doRequestAuth, CancellationToken cancellationToken)
at System.Net.Http.DiagnosticsHandler.SendAsyncCore(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
at System.Net.Http.RedirectHandler.SendAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
at Grpc.Net.Client.Internal.GrpcCall`2.RunCall(HttpRequestMessage request, Nullable`1 timeout)")
ProtoBuf.Grpc.Internal.Reshape.UnaryTaskAsyncImpl<TRequest, TResponse>(AsyncUnaryCall<TResponse> call, MetadataContext metadata, CancellationToken cancellationToken) in Reshape.cs, line 289
Document Details
⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
- ID: c730b5f9-031e-beab-b838-6e2f8befde30
- Version Independent ID: 84ddcb67-03be-655c-470a-f43a5152606f
- Content: Troubleshoot gRPC on .NET Core
- Content Source: aspnetcore/grpc/troubleshoot.md
- Product: aspnet-core
- Technology: aspnetcore-grpc
- GitHub Login: @JamesNK
- Microsoft Alias: jamesnk
Why do you want to not use HTTPS?
Why do you want to not use HTTPS?
Because the Doc said it's possible? Just want to explore every bits of gRPC in .NET.
The Kestrel endpoint must be Http2 only. Http1AndHttp2 will default to HTTP/1.1 without TLS.
@JamesNK So it's server only, the client will just work without any additional changes?
What about ASP.NET core as client?
Why do you want to not use HTTPS?
E.g. in a constrained network (in an intranet) to send data between machines. No need for HTTPS, as the network isn't accessible by others. Say on a production site where for IIoT machine data is sent to a collector server. Or is there still an advantage to use HTTPS in such scenarios?
@JamesNK So it's server only, the client will just work without any additional changes?
No, the client changes on the troubleshooting page are required for .NET Core 3.
What about ASP.NET core as client?
That doesn't matter.