Android Question gRPC client

advansis

Active Member
Licensed User
Longtime User
Hi guys,
I have a server (my own) responding to gRPC calls. It is done in C#/dotnetcore and works very well in desktop applications.
Cannot find anything in B4A to create a simple client (one rpc greeter would be enough).
Android supports it: a good starting point can be this: https://grpc.io/docs/quickstart/android/
But I have no ideas to port it in B4A.
Any example/clue/hint? Thanks
 

tigrot

Well-Known Member
Licensed User
Longtime User
It seems a limited use package, as far as I understand(I'm not an english speaking), the package allows only connection over a USB cable,
If I where you I'd port the RPC of the server under a WEBSERVICE. Much easyer to port to B4A.
 
Upvote 0

advansis

Active Member
Licensed User
Longtime User
gRPC (https://grpc.io/) is a high-performance RPC framework. It is not limited and is open-source. The protocol can work over HPPTS and can send data and streams (sync and async). Visual Studio 2019 can be used to create gRPC server and client (by now, only in C#). The great thing is that it can be run under application servers, but also under Kestrel.
@DonManfred, I need to execute RPC calls (defined in a "Proto" definition file)
Thanks
 
Last edited:
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
@DonMafred, I need to execute RPC calls (defined in a "Proto" definition file)
My username is DonManfred.

There is no lib for gprc in b4a.

Again: What Api EXACTLY are you trying to access?? <--- !

You probably can call this api using okhttputils2 (without the need for a GPRC library).
 
Last edited:
Upvote 0

advansis

Active Member
Licensed User
Longtime User
there is no lib for gprc in b4a.

Again: What Api EXACTLY are you trying to access???? <--- !!!
You probably can call this api using okhttputils2.

Of course I can call API with okhttputils, https://mvnrepository.com/artifact/io.grpc/grpc-okhttp
but the protocol inside is not as easy as it seems (data are 7bit long and is used a compression algorithm).

I have my own gRPC server with my own greeters. A call can be this (in Java):
Java:
try {
    HelloRequest message = HelloRequest.newBuilder().setName(mMessage).build();
    HelloReply reply = stub.sayHello(message);
    reply = stub.sayHelloAgain(message);
} catch (Exception e) {
    StringWriter sw = new StringWriter();
    PrintWriter pw = new PrintWriter(sw);
    e.printStackTrace(pw);
    pw.flush();
    return "Failed... : " + System.lineSeparator() + sw;
}

This is the Proto definition:
B4X:
// The greeting service definition.
service Greeter {
  // Sends a greeting
  rpc SayHello (HelloRequest) returns (HelloReply) {}
  // Sends another greeting
  rpc SayHelloAgain (HelloRequest) returns (HelloReply) {}
}

// The request message containing the user's name.
message HelloRequest {
  string name = 1;
}

// The response message containing the greetings
message HelloReply {
  string message = 1;
}

I realized there's no library in B4A, but Android has. I asked if someone have already translated the java libraries (even partially, I can improve and publish all the code).
I don't know how to start and include/call such libraries...

@DonManfred , in your FireBase library (https://www.b4x.com/android/forum/threads/firebase-cloud-firestore.105067/#content) you already use such libraries...

Thank you
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…