Can you try updating your dependencies? I just tried running the given code with the latest versions of grpc and @grpc/proto-loader and it worked. There was previously an issue that the library would not accept method names with the same casing as in the original proto file, but that was fixed a while ago.
As a side note, the `keepCase` option in `proto-loader` affects message field names. If it is not set, the field names are transformed to camel case. On Mon, Mar 11, 2019 at 8:14 AM 'Mya Pitzeruse' via grpc.io < [email protected]> wrote: > On the server side, try using lowercase names instead of title case: > > server.addService(test.Greeter.service, { > sayHello: SayHello, > sayHelp: SayHelp > }); > > I would assume that using "keepCase: true" meant that they would require > these to be the same as the proto. But here's an example where I use the > same loader semantic and the same casing: > > https://github.com/mjpitz/des/blob/master/api/extractor.proto#L19 > https://github.com/mjpitz/des/blob/master/api/extractor.js#L8 > > And all of my service methods are use camel case instead of the case I > used in the proto file: > > https://github.com/mjpitz/des/blob/master/src/service/unasyncify.ts#L9 > > > On Sat, Mar 9, 2019 at 10:08 AM Rob Cecil <[email protected]> wrote: > >> I'm experienced with Grpc - having built iOS/ObjC front-end and C# >> backend over a two year period (a Grpc project consisting of a main proto >> with a service that has 27 methods, and about a dozen supporting protos for >> message definitions). >> >> I am however, not super experienced with web development, so I am a >> little frustrated atm, trying to get simple things to work with Grpc-node. >> I started with something simple - the HelloWorld example and modified it >> from there. >> >> Here is my current "test.proto": >> >> syntax = "proto3"; >> >> >> package helloworld; >> >> >> service Greeter { >> rpc SayHello(FooBarRequest) returns (FooBarReply); >> rpc SayHelp(FooBarRequest) returns (FooBarReply); >> } >> >> >> message FooBarRequest { >> string name = 1; >> } >> >> message FooBarReply { >> string message = 1; >> } >> >> >> server.js: >> >> const _ = require('lodash'); >> const grpc = require('grpc'); >> const protoLoader = require('@grpc/proto-loader'); >> >> >> const argv = require("minimist")(process.argv.slice(2)); >> console.dir(argv); >> >> >> if (!argv.h) { >> console.log("Please start server.js with -h xx.xx.xx.xx:xxxx"); >> process.exit(1); >> } >> console.log(`Starting server.js on : ${argv.h}`); >> >> >> const PROTOS_PATH = __dirname + '/../protos/'; >> const BESERVICE_PROTO_PATH = PROTOS_PATH + 'test.proto'; >> >> >> const beDefinition = protoLoader.loadSync( >> BESERVICE_PROTO_PATH, >> {keepCase: true, >> longs: String, >> enums: String, >> defaults: true, >> oneofs: true >> }); >> >> >> const test = grpc.loadPackageDefinition(beDefinition).helloworld; >> >> >> function SayHello(call, callback) { >> callback(null, {message: 'Hello ' + call.request.name}); >> } >> >> >> function SayHelp(call, callback) { >> callback(null, {message: 'Help! ' + call.request.name}); >> } >> >> >> function main() { >> var server = new grpc.Server(); >> server.addService(test.Greeter.service, { >> SayHello: SayHello, >> SayHelp: SayHelp >> }); >> server.bind(argv.h, grpc.ServerCredentials.createInsecure()); >> server.start(); >> } >> >> main(); >> >> >> >> >> >> client.js: >> >> const grpc = require('grpc'); >> const util = require('util') >> const protoLoader = require('@grpc/proto-loader'); >> const argv = require("minimist")(process.argv.slice(2)); >> console.dir(argv); >> >> >> if (!argv.h) { >> console.log("Please start with -h xx.xx.xx.xx:xxxx"); >> process.exit(1); >> } >> console.log(`Starting Node backend client on : ${argv.h}`); >> >> >> const PROTOS_PATH = __dirname + '/../protos/'; >> const BESERVICE_PROTO_PATH = PROTOS_PATH + 'test.proto'; >> >> >> const beDefinition = protoLoader.loadSync( >> BESERVICE_PROTO_PATH, >> {keepCase: true, >> longs: String, >> enums: String, >> defaults: true, >> oneofs: true >> }); >> >> >> const test = grpc.loadPackageDefinition(beDefinition).helloworld; >> >> >> function main() { >> var client = new test.Greeter(argv.h, grpc.credentials.createInsecure >> ()); >> >> client.SayHello({ name: 'Darth' }, {}, (err, response) => { >> if (err) { >> console.error("error calling SayHello", err); >> return >> } >> console.log('Greeting:', response.message); >> >> >> client.SayHelp({ name: 'Darth' }, {}, (err, response) => { >> if (err) { >> console.error("error calling SayHelp", err); >> return >> } >> console.log('Help! ', response.message); >> }); >> }); >> } >> >> main(); >> >> >> I run the client and server on the same machine, using the same command >> line argument for the same host & port. >> >> Can anyone explain why I get "RPC method not implemented" on the second >> method defined in the Greeter service above? >> >> wander@peniche:~/control-web/js$ !1186 >> node server.js -h 172.16.0.168:9090 & >> [1] 57465 >> wander@peniche:~/control-web/js$ { _: [], h: '172.16.0.168:9090' } >> Starting server.js on : 172.16.0.168:9090 >> >> >> wander@peniche:~/control-web/js$ !1187 >> node backendservice-node-client.js -h 172.16.0.168:9090 >> { _: [], h: '172.16.0.168:9090' } >> Starting Node backend client on : 172.16.0.168:9090 >> Greeting: Hello! Darth >> error calling SayHelp { Error: 12 UNIMPLEMENTED: RPC method not >> implemented /helloworld.Greeter/SayHelp >> at Object.exports.createStatusError (/home/wander/control-web/ >> node_modules/grpc/src/common.js:91:15) >> at Object.onReceiveStatus (/home/wander/control-web/node_modules/grpc >> /src/client_interceptors.js:1204:28) >> at InterceptingListener._callNext (/home/wander/control-web/ >> node_modules/grpc/src/client_interceptors.js:568:42) >> at InterceptingListener.onReceiveStatus (/home/wander/control-web/ >> node_modules/grpc/src/client_interceptors.js:618:8) >> at callback (/home/wander/control-web/node_modules/grpc/src/ >> client_interceptors.js:845:24) >> code: 12, >> metadata: Metadata { _internal_repr: {} }, >> details: 'RPC method not implemented /helloworld.Greeter/SayHelp' } >> >> >> If i remove the SayHelp method in the proto and update the client & >> server code, it works fine. >> >> THANKS >> >> -- >> 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]. >> Visit this group at https://groups.google.com/group/grpc-io. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/grpc-io/3c7c48bc-3612-4c7e-9b30-9a30e47d1286%40googlegroups.com >> <https://groups.google.com/d/msgid/grpc-io/3c7c48bc-3612-4c7e-9b30-9a30e47d1286%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> For more options, visit https://groups.google.com/d/optout. >> > > > -- > > Mya Pitzeruse > > Senior Software Engineer - Service Infrastructure > > Gender Pronouns: She, Her, Hers > > [email protected] > > > Indeed - We help people get jobs. > > Indeed.com <http://www.indeed.com/> > > Facebook <http://www.facebook.com/indeed> | > <http://www.twitter.com/indeed> > -- 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]. Visit this group at https://groups.google.com/group/grpc-io. To view this discussion on the web visit https://groups.google.com/d/msgid/grpc-io/CAPK2-4dND%2BBvQ%2BE6%2BeaZffAg5-Z%3Dbi%3Dne0%2BaYBr1%3D%2BpGbnywjA%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
smime.p7s
Description: S/MIME Cryptographic Signature
