protobuf-net.Grpc | GRPC bindings for protobuf-net and grpc-dotnet
kandi X-RAY | protobuf-net.Grpc Summary
kandi X-RAY | protobuf-net.Grpc Summary
protobuf-net.Grpc adds code-first support for services over gRPC using either the native Grpc.Core API, or the fully-managed Grpc.Net.Client / Grpc.AspNetCore.Server API. It should work on all .NET languages that can generate something even remotely like a regular .NET type model.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of protobuf-net.Grpc
protobuf-net.Grpc Key Features
protobuf-net.Grpc Examples and Code Snippets
Community Discussions
Trending Discussions on protobuf-net.Grpc
QUESTION
I have a .Net Standard 2.0 class library that uses Protobuf-net.grpc's code first approach to define a gRPC service. In this definition I have classes defining different data structures that we are using to record sensor data and serialize this out using protobuf-net. My programs are ingesting serveral hundred thousand large objects /s (which will soon scale into the millions) and are intended to be used in embedded environments.
ProblemIn my class below, I would like to include as a member a System.Numerics.Quaterion. I cannot seem to get this serialized out. Using static constructors, the RuntimeTypeModel throws exceptions as the Quaternion model has somehow already been created by the time the static constructor is executed. As this is a class library, and I desperately want to avoid invoking the RuntimeTypeModel in each different program using the gRPC service. I'm hoping to find a way to serialize the System.Numerics.Quaternion.
I have tried placing this static constructor runtime definition at the highest level of the class hierarchy to no avail. Exceptions still thrown.
...ANSWER
Answered 2020-Oct-29 at 10:25This is ultimately a timing problem - when the serializer attempts to reflect on SensorData
to prepare the serializer, the static constructor in IMUData
has not yet executed, so it prepares the serializer with incomplete information, and then later the static constructor tries to reconfigure the model - too late.
If you use C# 9.0, you can fix this by using a module initializer instead of a static constructor (if we assume that SensorData
and IMUData
are in the same module, which is probably a safe assumption). The following works fine, for example:
QUESTION
i try to use a custom protobuf-net RuntimeTypeModel with the protobuf-net grpc client library. What I understand so far, I need to to use the ClientFactory and set a binder-configuration which references my RuntimeTypeModel-Instance.
...ANSWER
Answered 2020-Sep-22 at 09:53You need to register the ClientFactory
with the DI layer:
QUESTION
I'm using protobuf-net.Grpc on a .NET Core server and trying to make calls from a .NET Framework (4.7.2.) gRPC Client. A full example is here: https://github.com/angelagyang/GRPCProtobufExample
Here is a snippet of my client:
...ANSWER
Answered 2020-Jul-09 at 23:06Solved and updated the original example: https://github.com/angelagyang/GRPCProtobufExample
You can configure a client certificate by creating a KeyCertificatePair
to pass into SslCredentials
. You will need the PEM encoded certificate chain and PEM encoded private key.
QUESTION
I am getting the following exception:
Microsoft.AspNetCore.Components.WebAssembly.Rendering.WebAssemblyRenderer[100] Unhandled exception rendering component: The type initializer for 'DefaultProxyCache
1' threw an exception. System.TypeInitializationException: The type initializer for 'DefaultProxyCache
1' threw an exception. ---> System.ArgumentException: Invalid generic arguments Parameter name: typeArguments at (wrapper managed-to-native) System.Reflection.RuntimeMethodInfo.MakeGenericMethod_impl(System.Reflection.RuntimeMethodInfo,System.Type[]) at System.Reflection.RuntimeMethodInfo.MakeGenericMethod (System.Type[] methodInstantiation) <0x342def8 + 0x000d6> in :0 at ProtoBuf.Grpc.Internal.ContractOperation.TryGetClientHelper () [0x0001b] in //src/protobuf-net.Grpc/Internal/ContractOperation.cs:291 at ProtoBuf.Grpc.Internal.ProxyEmitter.EmitFactory[TService] (ProtoBuf.Grpc.Configuration.BinderConfiguration binderConfig) [0x00477] in //src/protobuf-net.Grpc/Internal/ProxyEmitter.cs:238 at ProtoBuf.Grpc.Internal.ProxyEmitter.CreateFactory[TService] (ProtoBuf.Grpc.Configuration.BinderConfiguration binderConfig) [0x0006d] in //src/protobuf-net.Grpc/Internal/ProxyEmitter.cs:123 at ProtoBuf.Grpc.Configuration.ClientFactory+DefaultProxyCache`1[TService]..cctor () [0x00000] in //src/protobuf-net.Grpc/Configuration/ClientFactory.cs:81
My project uses gRPC-Web, Blazor web assembly and protobuf-net
This is my service contract:
...ANSWER
Answered 2020-Jul-07 at 07:38That is... odd. I can't repro it here, so I'm guessing it is something specific to Blazor. I've checked what the code does in the "regular" frameworks, and at least for me it seems to do the right things - using UnaryValueTaskAsync()
and UnaryValueTaskAsync()
, which is what I would expect. I've improved the exception handling in that code path, to at least give us a clue what it is trying to do, so my suggestion is:
- update to
protobuf-net.Grpc
version >= 1.0.119 (I'll get it deployed as soon as CI finishes) - retry, and let me know exactly what it says now
Alternatively, if you have a minimal repro including the blazor bits on, say, a GitHub repo, I can happily take a look there.
(tip: I try to keep an eye on both Stack Overflow and GitHub, but GitHub is probably more appropriate for this kind of question - I'd happily say that this is a bug, so: https://github.com/protobuf-net/protobuf-net.Grpc/issues)
QUESTION
I am using protobuf-net with protobuf-net.grpc and am attempting to get it to work on Xmarin/Ios.
Currently I have attempted to create a pre-compiled serializer:
...ANSWER
Answered 2020-Jun-25 at 17:13A second read on this reveals that you're actually looking for gRPC support. This is actually possible right now - you just need to provide a custom binder config:
QUESTION
I am upgrading an application from .Net FW to .Net Core. Also upgrading WCF services to gRPC services. We have decided to use protobuf-net.Grpc.
We use multiple levels of inheritance for service contracts.
...ANSWER
Answered 2020-May-12 at 02:20This would be a great bug to report on github. The problem is that the contract binder does not unroll generics, so you end up with multiple services on the same names, with the .NET generic placeholder (but different APIs internally):
QUESTION
I am experimenting with a gRPC service and client using proto files. The advice is to use gRPC client factory integration in .NET Core (https://docs.microsoft.com/en-us/aspnet/core/grpc/clientfactory?view=aspnetcore-3.1). To do this you register the client derived from Grpc.Core.ClientBase that is generated by the Grpc.Tools package, like this:
...ANSWER
Answered 2020-Mar-26 at 14:54Note that you don't need the AllowUnencryptedHttp2
- that's just if you aren't using https, but: you seem to be using https.
On the "similarly"; that should already work - the only bit you might be missing is the call to services.AddCodeFirstGrpc()
(usually in Startup.cs
, via ConfigureServices
).
As for the AddGrpcClient
; I would have to investigate. That isn't something that I've explored in the integrations so far. It might be a new piece is needed.
QUESTION
I'm currently working on replacing an old WCF client/server pairing with gRpc, and decided to use protobuf-net.Grpc as we've used protobuf-net extensively elsewhere in our codebase. I'm running into a bit of trouble with one particular portion however.
Part of the original service is a Subscribe method which uses IClientCallback to effectively send an event to the client. Looking at regular gRpc, it seems like this would be possible (though a bit hacky) using a server streaming method and storing the IServerStreamWriter object on the server, writing to it whenever we wanted to "fire an event".
For the life of me, however, I can't quite figure out how to do something similar in protobuf-net.Grpc with the IAsyncEnumerable return type. The closest I can figure is using Task.Wait in a loop and updating some shared collection when I want to "fire" the event, which the loop would then check for and yield return. This doesn't seem like it'd scale well, however, and there isn't really a great way to definitely unsubscribe when a client is no longer listening to events.
Is there some other/better way to do this?
...ANSWER
Answered 2020-Feb-26 at 22:31Channel
, which can be tweaked via AsAsyncEnumerable()
- which then essentially acts as a queue at the producer side, and a sequence at the consumer.
QUESTION
So, recently I learned about how to do streaming with protobuf-net.grpc with the help of IAsyncEnumerable
. This all works fine and dandy, but I'm facing a bit of an issue right now.
For some of my calls, I'd like to call with both some metadata as well as the stream as parameter.
For example:
...ANSWER
Answered 2020-Feb-01 at 14:23There are two separate concepts here:
- gRPC allows a stream of messages via
IAsyncEnumerable
(instead of aTask
for a single message) - however, each individual message must be complete and self contained; the marshaller (per-message serializer) is synchronous only
So: you can use IAsyncEnunerable
as the parameter or return of a service method, but not as a field on a message.
If you need to provide a stream and additional metadata a few options exist:
- use http headers (via
CallContext
as a second parameter) - have two service calls - one that initiates things and gets the metadata, one that returns the stream
- have a stream with some optional fields in the message, and only populate the optional fields in the first or last message
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install protobuf-net.Grpc
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page