Questions tagged [grpc-java]

Java version of general RPC (Remote Procedure Call) framework over HTTP/2.

Links

What is gRPC?

In gRPC a client application can directly call methods on a server application on a different machine as if it was a local object, making it easier for you to create distributed applications and services. As in many RPC systems, gRPC is based around the idea of defining a service, specifying the methods that can be called remotely with their parameters and return types. On the server side, the server implements this interface and runs a gRPC server to handle client calls. On the client side, the client has a stub (referred to as just client in some languages) that provides the same methods as the server.

By default gRPC uses protocol buffers, Google’s mature open source mechanism for serializing structured data (although it can be used with other data formats such as JSON). As you’ll see in our example below, you define gRPC services using proto files, with method parameters and return types specified as protocol buffer message types. You can find out lots more about protocol buffers in the Protocol Buffers documentation.

863 questions
39
votes
4 answers

java.lang.NoSuchMethodError: com.google.common.base.Preconditions.checkArgument

I am trying to run this grpc-Java example on my local. Corresponding proto file for the same is here. When i try to run in on local it throws the following exception from here : Exception in thread "main" java.lang.NoSuchMethodError:…
Naresh
  • 5,073
  • 12
  • 67
  • 124
37
votes
9 answers

How to add global exception interceptor in gRPC server?

In gRPC , how to add a global exception interceptor that intercepts any RuntimeException and propagate meaningful information to the client ? for example , a divide method may throw ArithmeticException with / by zero message . In the server side , I…
smallufo
  • 11,516
  • 20
  • 73
  • 111
27
votes
1 answer

What is the exact use of the executor in grpc-java’s ServerBuilder? Does it just execute the handler methods?

grpc-java uses an executor in its ServerBuilder, which if not defined by the builder.executor() method, uses a static cached thread pool by default. What is the exact use of this executor? Does it just execute the handler methods or does it do…
gravetii
  • 9,273
  • 9
  • 56
  • 75
25
votes
1 answer

Android How to add a custom header in grpc client?

I have to add a custom header in an android grpc client. I am unable to send it successfully. public class HeaderClientInterceptor implements ClientInterceptor { @Override public < ReqT, RespT > ClientCall < ReqT, RespT >…
rana
  • 1,824
  • 3
  • 21
  • 36
22
votes
5 answers

How to convert Google proto timestamp to Java LocalDate?

We need to convert Google Proto buffer time stamp to a normal date. In that circumstance is there any way to convert Google Proto buffer timestamp to a Java LocalDate directly?
Thirunavukkarasu
  • 361
  • 1
  • 2
  • 13
20
votes
2 answers

Multiple unary rpc calls vs long-running bidirectional streaming in grpc?

I have a use case where many clients need to keep sending a lot of metrics to the server (almost perpetually). The server needs to store these events, and process them later. I don't expect any kind of response from the server for these events. I'm…
avmohan
  • 1,820
  • 3
  • 20
  • 39
19
votes
1 answer

Can I run multiple GRPC services on same port

I'm working on gRPC and I want to run multiple services on same port Server server = ServerBuilder.forPort(8080) .addService(new HelloServiceImpl()) .addService(new ByeServiceImpl()) .build(); Is this the right way to run multiple GRPC…
Azeem Haider
  • 1,443
  • 4
  • 23
  • 41
19
votes
2 answers

Does gRPC server spin up a new thread for each request?

I tried profiling a gRPC java server. And i see the below set of thread pools majorly. grpc-default-executor Threads : Created 1 for each incoming request. grpc-default-worker-ELG Threads: May be to listen on the incoming gRPC requests & assign to…
Venkata Naresh
  • 377
  • 1
  • 2
  • 9
19
votes
2 answers

Connection Error io.netty.handler.codec.http2.Http2Exception: HTTP/2 client preface string missing or corrupt. Hex dump for received bytes:

Working on Grpc Bidirectional Streaming, when i try to run grpc, getting below error Connection Error io.netty.handler.codec.http2.Http2Exception: HTTP/2 client preface string missing or corrupt. Hex dump for received bytes: at…
Gayathri
  • 221
  • 1
  • 3
  • 8
19
votes
6 answers

gRPC Load Balancing

I have read the Load Balancing page at https://github.com/grpc/grpc/blob/master/doc/load-balancing.md to start of, but still am confused as to the right approach to loadbalancing between back end GRPC instances. We are deploying multiple gRPC…
user3707
  • 1,470
  • 2
  • 15
  • 21
18
votes
1 answer

gRPC: Random CANCELLED exception on RPC calls

I'm occasionally getting cancellation errors when calling gRPC methods. Here's my client-side code (Using grpc-java 1.22.0 library): public class MyClient { private static final Logger logger = LoggerFactory.getLogger(MyClient.class); …
hylowaker
  • 966
  • 2
  • 9
  • 24
18
votes
6 answers

Grpc.Core.RpcException method is unimplemented with C# client and Java Server

I am having trouble finding the source of this error. I implemented a simple service using protobuf: syntax = "proto3"; package tourism; service RemoteService { rpc Login(LoginUserDTO) returns (Response) {} } message AgencyDTO{ int32 id=1; …
Alexandru Cancescu
  • 829
  • 1
  • 9
  • 19
17
votes
2 answers

gRPC call, channel, connection and HTTP/2 lifecycle

I read the gRPC Core concepts, architecture and lifecycle, but it doesn't go into the depth I like to see. There is the RPC call, gRPC channel, gRPC connection (not described in the article) and HTTP/2 connection (not described in the article). I'm…
Abhijit Sarkar
  • 21,927
  • 20
  • 110
  • 219
15
votes
1 answer

gRPC connection: use keepAlive or idleTimeout?

Looking at gRPC Java doc - ManagedChannelBuilder, there're two options to manage the connections. It seems idleTimeout() is the default/preferred configuration. But when I tried to search for a comparison, most of the posts are talking about…
xialin
  • 7,686
  • 9
  • 35
  • 66
15
votes
1 answer

How can a gRPC server notice that the client has cancelled a server-side streaming call?

I want to use gRPC to let clients subscribe to events generated by the server. I have an RPC declared like so: rpc Subscribe (SubscribeRequest) returns (stream SubscribeResponse); where the returned stream is infinite. To "unsubscribe", clients…
Balz Guenat
  • 1,552
  • 2
  • 15
  • 35
1
2 3
57 58