Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Grpc.Net.ClientFactory .NETStandard2.0 compatibility #1247

Closed
Dimigergo opened this issue Mar 18, 2021 · 8 comments · Fixed by #1248
Closed

Grpc.Net.ClientFactory .NETStandard2.0 compatibility #1247

Dimigergo opened this issue Mar 18, 2021 · 8 comments · Fixed by #1248
Labels
enhancement New feature or request

Comments

@Dimigergo
Copy link

Is your feature request related to a problem? Please describe.

I hava an UWP project which uses Grpc.Net.Client.Web 2.36.0. I see, that this version supports .NETStandard2.0, but the
Grpc.Net.ClientFactory only supports .NETStandard2.1 and net5.0.
The UWP doesn't support 2.1 or .net5 yet.

My problem is I would like to use interceptors for the client side, according to this code:

services
    .AddGrpcClient<Greeter.GreeterClient>(o =>
    {
        o.Address = new Uri("https://localhost:5001");
    })
    .AddInterceptor(() => new SomeInterceptor())   

Describe the solution you'd like

Grpc.Net.ClientFactory .NETStandard2.0 compatibility

Describe alternatives you've considered

Closely enough to me that add multiple interceptor with somewhere on these lines:

CallCredentials callCredentials = CallCredentials.FromInterceptor(CHttpClientService.AsyncAuthInterceptor);
    return GrpcChannel.ForAddress(Settings.CSettings.ServerAddress, new GrpcChannelOptions
    {
        HttpHandler = new GrpcWebHandler(new CHttpClientService().PrepareHttpMessageHandler()),
        Credentials = ChannelCredentials.Create(new SslCredentials(), callCredentials),
    });

AsyncAuthInterceptor is not good for me, because it is called only before the function call.

@Dimigergo Dimigergo added the enhancement New feature or request label Mar 18, 2021
@HppZ
Copy link

HppZ commented Mar 18, 2021

need .NETStandard2.0 support toooo

@JamesNK
Copy link
Member

JamesNK commented Mar 18, 2021

netstandard2.0 client factory will be in the next release.

You can add interceptors like this to a channel without client factory:

var channel = GrpcChannel.ForAddress("https://blah");
var invoker = channel.Intercept(new SomeInterceptor());

var client = Greeter.GreeterClient(invoker);

The extension method is in Grpc.Core.Interceptors.ChannelExtensions.

@Dimigergo
Copy link
Author

Thank you for your help!
Waiting for the release.

@HppZ
Copy link

HppZ commented Mar 21, 2021

gRPC requires extra configuration on .NET implementations that don't support gRPC over HTTP/2. An HTTP provider must be specified using GrpcChannelOptions.HttpHandler.The configured HTTP provider must either support HTTP/2 or be configured to use gRPC-Web. See https://aka.ms/pzkMXDs for details.

so grpc.net.client does not support UWP?

@Dimigergo
Copy link
Author

Grpc.Net.Client 2.36.0 is compatible with .netstandard2.0 so you can use it in UWP project. I only use grpc-web, because we have this project in Uno Platform, and compile it to webassembly, where we can't use grpc, only grpc-web.

@HppZ
Copy link

HppZ commented Mar 22, 2021

I have to set GrpcWebHandler as grpc httphandler in UWP app. here

@Dimigergo
Copy link
Author

Ohh, I see! Microsoft will plan to support .netstandard2.1 and .net 5 for UWP, but don't know when. 21H1 os 21H2. We also wait for it.

@HppZ
Copy link

HppZ commented Mar 22, 2021

hope it won't be long. so sad.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants