AspNetCore.Docs icon indicating copy to clipboard operation
AspNetCore.Docs copied to clipboard

gRPC with HTTP endpoint

Open JerryBian opened this issue 4 years ago • 6 comments

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.

JerryBian avatar Dec 11 '21 14:12 JerryBian

Why do you want to not use HTTPS?

Rick-Anderson avatar Dec 11 '21 17:12 Rick-Anderson

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.

JerryBian avatar Dec 12 '21 00:12 JerryBian

The Kestrel endpoint must be Http2 only. Http1AndHttp2 will default to HTTP/1.1 without TLS.

JamesNK avatar Dec 12 '21 01:12 JamesNK

@JamesNK So it's server only, the client will just work without any additional changes?

What about ASP.NET core as client?

JerryBian avatar Dec 12 '21 04:12 JerryBian

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?

gfoidl avatar Dec 12 '21 10:12 gfoidl

@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.

JamesNK avatar Dec 12 '21 23:12 JamesNK