loopback4-extension-grpc
loopback4-extension-grpc copied to clipboard
Not starting GRPC server
Description/Steps to reproduce
- Scaffolded a LB 4 app as "loopback4-example-express-composition"
- $ npm install --save @loopback/grpc
- Modified Index.ts file with the code explained in the section "Component Configuration" of https://www.npmjs.com/package/@loopback/grpc
- Followed the rest of the steps as mentioned in npm module "@loopback/grpc"
Link to reproduction sandbox
Expected result
- Suppose to generate "greeter.proto.ts", but it never generate the .tc file for the proto file.
- Copied the greeter.proto.ts file from "loopback4-extension-grpc/fixtures/greeter.proto.ts" to my above application.
- When I run "$npm start", it does not throw any error but the command prompt returns and server is not listening to any specific port.
Additional information
- How can I make the client application to call this server?
- How can I extend this to make grpc stream calls between client and server on loopback 4.
@raymondfeng , could you please take a look? Thanks.
@hsenapati Can you try @loopback/[email protected]?
@raymondfeng The path I mentioned with the issue "https://www.npmjs.com/package/@loopback/grpc" is for 0.1.1 revision, I suppose. Can you help providing sample code. Thanks
I just released @loopback/[email protected]
15 mins ago. Please upgrade your app to this version and try again.
Thanks @raymondfeng for the details.
The grpc npm package works for Hello World on linux, but following changes were done to make the Hello World work on Windows 64 bit.
- Changed code block for “Component.Configuration” part from “const config: Config.Component” to “const config: object”
- Grpc compiler for LB4 is not installed as part of grpc npm module. So manually copied compiler to “node_modules@loopback\grpc”
- Controller code should not refer the .proto file till the proto.ts is generated by the compiler.
- We had to install “npm install ts-protoc-gen@next” as opposed to “npm install ts-protoc-gen” to make the grpc compiler generate the compiled protos file.
- Updated the compiler command file from “protoc-gen-ts” to “protoc-gen-ts.cmd” in the “node_modules@loopback\grpc\dist\grpc.generator.js” for the compiler to work.
- It does not generate proto.ts file with interfaces which is required for grpc server to instantiate. But it compiles to following 3 files for a single greeter.proto file a. greeter_pb_service.d.ts b. greeter_pb_service.js c. greeter_pb.d.ts
- So manually had to copy the proto.ts file from the linux machine which had the required interfaces.
- Now, LB4 + gRPC Server started.
- Now for client, used NodeJS grpc client (non-LB4 client) as her "https://grpc.io/docs/quickstart/node/" to send a simple message to server. This worked.
Following are the open challenges
- Can you update the grpc npm module of LB4 to make the above fixes for windows 64 bit.
- No sample code available to work for grpc client, streaming call (bidirectional) and authentication etc. So can you provide or point up code references for us to try out.