-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Description
Is there an existing issue for this?
- I have searched the existing issues
Describe the bug
After I updated my project to net8 I started to receive the following error
Grpc.Core.RpcException: Status(StatusCode="Internal", Detail="Error starting gRPC call. HttpRequestException: Application layer protocol negotiation error was encountered. (localhost:5001) AuthenticationException: Application layer protocol negotiation error was encountered.", DebugException="System.Net.Http.HttpRequestException: Application layer protocol negotiation error was encountered. (localhost:5001)") ---> System.Net.Http.HttpRequestException: Application layer protocol negotiation error was encountered. (localhost:5001) ---> System.Security.Authentication.AuthenticationException: Application layer protocol negotiation error was encountered.
Not sure if grpc is supported or not yet. I can try and triage if needed.
Expected Behavior
The following code is where the exception occurs. This just started happening after i moved the project to net8 without any other changes.
protected readonly string url = @"https://localhost:5001/";
var channel = GrpcChannel.ForAddress(url, new GrpcChannelOptions { HttpHandler = httpHandler });
client = new ClientIPC.ClientIPCClient(channel);
var response = await client!.GetServerStatusAsync(new Empty { });
Relevant Configure services
public void ConfigureServices(IServiceCollection services)
{
services.AddResponseCompression(options => { options.MimeTypes.Concat(new[] { "application/octet-stream", "application/wasm" }); });
services.AddGrpc(options => { options.EnableDetailedErrors = true; options.ResponseCompressionLevel = CompressionLevel.Optimal; options.ResponseCompressionAlgorithm = "gzip"; });
services.AddCors(o =>
{
o.AddPolicy("CorsPolicy", builder =>
{
builder.AllowAnyOrigin();
builder.AllowAnyHeader();
builder.AllowAnyMethod();
// TODO tighten this up
//builder.WithOrigins("localhost:443", "localhost", "YourCustomDomain");
// builder.WithMethods("POST, OPTIONS");
//builder.AllowAnyHeader();
builder.WithExposedHeaders("Grpc-Status", "Grpc-Message","Grpc-Encoding", "Grpc-Accept-Encoding", "X-Grpc-Web", "User-Agent");
});
});
}
Relevent Configure
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
app.UseWebAssemblyDebugging();
}
app.UseHttpsRedirection();
app.UseResponseCompression();
app.UseRouting();
// Must be between UseRouting() and UseEndPoints()
app.UseCors("CorsPolicy");
app.UseCookiePolicy();
app.UseGrpcWeb();
app.UseBlazorFrameworkFiles();
app.UseStaticFiles(new StaticFileOptions { FileProvider = app.ApplicationServices?.GetRequiredService<RemoteFileResolver>() });
app.UseEndpoints(endpoints =>
{
endpoints.MapGrpcService<RemoteWebViewService>().AllowAnonymous();
endpoints.MapGrpcService<ClientIPCService>().EnableGrpcWeb().AllowAnonymous().RequireCors("CorsPolicy");
endpoints.MapGrpcService<BrowserIPCService>().EnableGrpcWeb().AllowAnonymous().RequireCors("CorsPolicy");
endpoints.MapGet("/mirror/{id:guid}", Mirror()).ConditionallyRequireAuthorization();
endpoints.MapGet("/app/{id:guid}", Start()).ConditionallyRequireAuthorization();
// Refresh from home page i.e. https://localhost/9bfd9d43-0289-4a80-92d8-6e617729da12/
endpoints.MapGet("/{id:guid}", StartOrRefresh()).ConditionallyRequireAuthorization();
// Refresh from nested page i.e.https://localhost/9bfd9d43-0289-4a80-92d8-6e617729da12/counter
endpoints.MapGet("/{id:guid}/{unused:alpha}", StartOrRefresh()).ConditionallyRequireAuthorization();
endpoints.MapGet("/wait/{id:guid}", Wait()).ConditionallyRequireAuthorization();
endpoints.MapGet("/test", () => "Hello World!");
endpoints.MapFallbackToFile("index.html");
});
}
Steps To Reproduce
No response
Exceptions (if any)
Grpc.Core.RpcException: Status(StatusCode="Internal", Detail="Error starting gRPC call. HttpRequestException: Application layer protocol negotiation error was encountered. (localhost:5001) AuthenticationException: Application layer protocol negotiation error was encountered.", DebugException="System.Net.Http.HttpRequestException: Application layer protocol negotiation error was encountered. (localhost:5001)") ---> System.Net.Http.HttpRequestException: Application layer protocol negotiation error was encountered. (localhost:5001) ---> System.Security.Authentication.AuthenticationException: Application layer protocol negotiation error was encountered.
.NET Version
8.0.100-preview.2.23157.25
Anything else?
No response