On Thursday, 18 August 2016 10:10:16 UTC-7, Kabloc Vacavoa wrote: > > Can I work with gRPC in C? Because I can refactor my server, that is made > in C, to communicate whit NodeJs client. > > Any ideas? > No because gRPC works with proto3 which does not have a C compiler. gRPC core is in C, so you do have low level APIs exposed under grpc/include/grpc but it means you would have to write a lot of boiler plate code in C.
If you want to use C, proto2 is your only option for now. Or you may have to write a proto2 to proto3 stub via a wrapper abstraction in library, which eventually calls proto3 based gRPC calls. Good luck > > On Thu, Aug 18, 2016 at 1:41 PM, Michael Lumish <[email protected] > <javascript:>> wrote: > >> protobuf-c-rpc and protobuf-rpc are not related to gRPC. Based on your >> use of ProtoBuf.Rpc.Transport.Xhr, it looks like they are using XML HTTP >> Requests instead. The C++ gRPC client will not work with one of those >> servers because it uses a completely different protocol. >> >> On Thu, Aug 18, 2016 at 4:39 AM <[email protected] <javascript:>> wrote: >> >>> I have new information about this problem... >>> >>> With a little modification on NodeJs code I got this error: >>> >>> Modification: >>> app.get('/have_pswd', function (req, res) { >>> var serv_req = new My_controller.Void(); >>> controller_svc.HavePassword(serv_req, function(error, serv_res) { >>> if (error !== null) throw error; >>> res.json(serv_res); >>> }); >>> }); >>> >>> Error: >>> RangeError: offset is not uint >>> at checkOffset (buffer.js:580:11) >>> at SlowBuffer.Buffer.readUInt32LE (buffer.js:642:5) >>> at null.rpcImpl >>> (/home/kabloc/work/server_controller/node_modules/protobuf-rpc/index.js:322:39) >>> at clazz.ServicePrototype.(anonymous function) [as HavePassword] >>> (/home/kabloc/work/server_controller/node_modules/protobufjs/dist/protobuf.js:4050:38) >>> at EventEmitter.app.listen.host >>> (/home/kabloc/work/server_controller/index.js:35:17) >>> at EventEmitter.emit (events.js:92:17) >>> at null._onTimeout >>> (/home/kabloc/work/server_controller/node_modules/protobuf-rpc/index.js:86:50) >>> at Timer.listOnTimeout [as ontimeout] (timers.js:110:15) >>> >>> Somebody have an idea about it? >>> >>> >>> On Wednesday, August 17, 2016 at 3:35:17 PM UTC-3, Kabloc Vacavoa wrote: >>>> >>>> OK, Sorry... >>>> >>>> Firstly sorry about my English... >>>> >>>> I have a project made in C that use protobuf-c-rpc to create a RPC >>>> procedures, that interfaces with others application in C normally. >>>> >>>> Now I need to do an application in NodeJs that uses the same interface, >>>> I tried by using protobuf-rpc: >>>> >>>> <CODE> >>>> >>>> var express = require('express'); >>>> var app = express(); >>>> var ProtoBuf = require('protobufjs'); >>>> ProtoBuf.Rpc = require('protobuf-rpc'); >>>> >>>> var builder = ProtoBuf.loadProtoFile("ControllerMessage.proto"); >>>> var My_controller = builder.build('MyPackage'); >>>> var controller_svc = new ProtoBuf.Rpc(My_controller.Controller, { >>>> transport: new ProtoBuf.Rpc.Transport.Xhr( {sync: true} ), >>>> url: 'http://127.0.0.1:5558' >>>> }); >>>> >>>> app.get('/have_pswd', function (req, res) { >>>> var serv_req = new My_controller.Void(); >>>> controller_svc.HavePassword(serv_req, function(error, serv_res) { >>>> if (error !== null) >>>> return res.status(500).send('error'); >>>> res.json(serv_res); >>>> }); >>>> }); >>>> >>>> var server = app.listen(9017, function(){ >>>> var host = server.address().address; >>>> var port = server.address().port; >>>> console.log('Example app listening at http://%s:%s', host, port); >>>> }); >>>> >>>> </CODE> >>>> >>>> When I send a GET to localhost:9017/have_pswd, I have a error(500). >>>> >>>> >>>> After that I tried by using grpc++: >>>> >>>> protoc --proto_path=. --grpc_out=. --plugin=protoc-gen-grpc=`which >>>> grpc_cpp_plugin` ControllerMessage.proto >>>> protoc --proto_path=. --cpp_out=. ControllerMessage.proto >>>> >>>> <CODE> >>>> >>>> #include <grpc++/grpc++.h> >>>> >>>> #include "ControllerMessage.pb.h" >>>> #include "ControllerMessage.grpc.pb.h" >>>> >>>> int main (int argc, char* argv[]) >>>> { >>>> std::unique_ptr<MyPackage::Controller::Stub> >>>> stub(MyPackage::Controller::NewStub( >>>> grpc::CreateChannel("localhost:5558", >>>> grpc::InsecureChannelCredentials()))); >>>> grpc::ClientContext cxt; >>>> MyPackage::Void req; >>>> MyPackage::Boolean res; >>>> >>>> stub->HavePassword(&cxt, req, &res); >>>> } >>>> >>>> >>>> </CODE> >>>> >>>> And on debug the line "stub->HavePassword(&cxt, req, &res);" make me >>>> wait forever. >>>> >>>> I would like to know what I did wrong... >>>> >>>> Thanks... >>>> >>>> On Wed, Aug 17, 2016 at 10:51 AM, Nathaniel Manista <[email protected] >>>> <javascript:>> wrote: >>>> >>>>> On Wed, Aug 17, 2016 at 6:13 AM, <[email protected] <javascript:>> >>>>> wrote: >>>>> >>>>>> I worked in a project that implemented a protocol buffers RPC in C >>>>>> using protobuf-c-rpc and now I'm trying develop a C++ or NodeJs client >>>>>> using grpc but it not working. >>>>>> >>>>> >>>>> How much more can you share with us about what's not working >>>>> <http://www.chiark.greenend.org.uk/~sgtatham/bugs.html>? >>>>> -Nathaniel >>>>> >>>> >>>> >>>> >>>> -- >>>> -- >>>> echo Gur orfg jnl gb cerqvpg gur shgher vf gb vairag vg: -- Nyna Xnl | >>>> tr N-ZA-Mn-za-m: A-Za-z. >>>> >>>> Kabloc Vacavoa >>>> google.com/profiles/kabloc >>>> >>> -- >>> You received this message because you are subscribed to the Google >>> Groups "grpc.io" group. >>> To unsubscribe from this group and stop receiving emails from it, send >>> an email to [email protected] <javascript:>. >>> To post to this group, send email to [email protected] >>> <javascript:>. >>> To view this discussion on the web visit >>> https://groups.google.com/d/msgid/grpc-io/32e31975-c088-437f-8f27-d5d7a7df7d30%40googlegroups.com >>> >>> <https://groups.google.com/d/msgid/grpc-io/32e31975-c088-437f-8f27-d5d7a7df7d30%40googlegroups.com?utm_medium=email&utm_source=footer> >>> . >>> For more options, visit https://groups.google.com/d/optout. >>> >> > > > -- > -- > echo Gur orfg jnl gb cerqvpg gur shgher vf gb vairag vg: -- Nyna Xnl | tr > N-ZA-Mn-za-m: A-Za-z. > > Kabloc Vacavoa > google.com/profiles/kabloc > -- You received this message because you are subscribed to the Google Groups "grpc.io" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/grpc-io/b9a9be1b-ccdb-40d6-904b-d9d8c5fbc8d8%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
