Jump to content

Recommended Posts

Can anyone recommend a GRPC client library for delphi. I have had a quick look around and only found a 1 open source lib - https://github.com/ultraware/DelphiGrpc  (no updates in 5 yrs), and nsoftware (which I will not buy as no source available).

 

Any others I have missed (open source or commercial with source code). 

 

 

Share this post


Link to post
1 hour ago, Darian Miller said:

I've been looking at that - since the DelphiGRPC makes use of it. Down the rabbit hole I go..

  • Like 1

Share this post


Link to post
3 hours ago, Vincent Parrett said:
4 hours ago, Darian Miller said:

I've been looking at that - since the DelphiGRPC makes use of it. Down the rabbit hole I go..

Well, i see sgcWebSockets folder there, this means the porting to sgcWebSockets is possible if not easy (or already there), DTLS with 1(or 0) handshake round-trip (with TLS1.3) and HTTP/2 are available, this will should get your attention, for performance and bandwidth utilization.

Share this post


Link to post

I looked at sgcWebSockets today - but the price is really steep - I don't need the rest of the library but http/2 is only in the most expensive version - and then I need to get gprc working on top of that. 

 

I'm actually leaning towards doing this project in c# (the server is already c#) -  testing with .net 8.0 AOT compilation so far produced a 4.5MB exe (+ a 12MB dll for google protocol buffers). Obviously it will be larger than that once done.

 

As much as I want to use delphi for this project - the libraries are just not there - contrast to dotnet - grpc is a first class citizen (and the performance is impressive). I was able to get up and running in less than 10 minutes  - contrast that to having spent most of today looking for a delphi grpc client that works. 

  • Like 3

Share this post


Link to post

Did you ever get GRCP working with the sgc libraries.

 

I tried to do a grpc call with TsgHTTP2Client which is partially successful in that it calls the server but I got an error in the response

 

//NON WORKING INCOMPLETE CODE FOR ILLUSTRATION PURPOSE ONLY
type TGRPCFrameHeader = packed record
B1:Byte;
Size:Cardinal;
end;
var FH:TGRPCFrameHeader;
httP:=TsgcHTTP2Client.Create(nil);
    http.request.TransferEncoding:='grpc-encoding';
   http.request.AcceptEncoding :='grpc-accept-encoding';
   http.request.AcceptEncoding :='';
    http.request.ContentType:='application/grpc+proto';
       http.ConnectTimeout:=10000;
    http.ReadTimeout:=10000;
    http.WriteTimeout:=10000;
    //http.request.CustomHeaders.AddPair('grpc-encoding','gzip');
    http.request.CustomHeaders.AddPair('TE','trailers');
   //Write header
FH.B1 :=0;
FH.Size := Length(BA);
	//Prepare byte array BA write 5 byte header then write message data
    outstream.write(FH,SizeOf(FH));
	outstream.Write(BA,Length(BA));
  http.post('http://127.0.0.1:50051/helloworld.Greeter/SayHello',outstream,memstream);

Finally I try to call the HelloWorld c plus plus server example in GRPC examples from git hub

 

where BA = image.thumb.png.2bfebc04752b06169c40f81d8478732f.png

 

When I do the call I get a list of strings back in http.reponse.headers one of which is

 

 grpc-message=Couldn't initialize byte buffer reader Process myGRPC.exe (21704)

 

I suspect my http2 headers are wrong.

 

I have to say GRPC is one of the worst things I have ever come across  to try to work with. 

 

I have managed to make a rudimentary framework which can read most proto files and to create a structures so that data can be stored against proto file data members in the correct format.

However I can not figure out how to make GRPC call over HTTP2. I don't know if I have to set some header flags

 

 

 

Share this post


Link to post

I am trying to link to an instrument that another company has made that uses GRPC to send data back to a controlling computer. I have managed to do this in C# but it has been a nightmare in C++ Builder and Delphi.

GRPC is supposed to be 10 years old now but so you would have thought it would be fairly stable at this point. However if you go on the news group https://groups.google.com/g/grpc-io you can see that

this trouble shooting group is very active with daily posts from people having problems with it. I guess GRPC was designed for interoperability between microservices in data centres where you have a lot of coders working on a distributed

architecture on many machines. The fact that GRPC has to author it's own code from proto files for each implementation makes it very hard for 3rd party providers to keep up. In my opinion GRPC is a bad technology in that it promises

ease of interoperability, but delivers complexity, bloat and obfuscation by the truck load. It's also a poorly documented project with out of date help files and examples that no longer work.

However if I can get things working natively in Delphi it will be a real triumph.

Edited by JackT

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×