This repository contains the source material for the Node.js gRPC codelab released at Google Cloud Platform Events. Access the codelab.
This is not an official Google product
Google Cloud Platform - Building a gRPC service with Node.js Source Repository
Home Page: https://codelabs.developers.google.com/codelabs/cloud-grpc/
License: Apache License 2.0
This repository contains the source material for the Node.js gRPC codelab released at Google Cloud Platform Events. Access the codelab.
This is not an official Google product
hi,
The last client.js you show in the last step has grpc.Credentials in the var client but it didn't work because it must be grpc.credentials. lower case.
At the end of the second slide, there is link to "using cloud shell". This link points to a Google Drive that requires special permission.
Perhaps "import" should be bold (according to the Codelab Formatting Guide)
I'm going through this tutorial and have already hit #5 / #6 due to grpc being updated since the tutorial was written. Now I've hit the following issue:
When https://codelabs.developers.google.com/codelabs/cloud-grpc/index.html?index=..%2F..%2Findex#4 instructs you to run "node server.js" for the first time, it doesn't say you should get an error, but you do:
$ node server.js
/Users/<user>/src/cloud-grpc/start/node_modules/grpc/src/node/src/server.js:735
throw new Error('Cannot add an empty service to a server');
^
Error: Cannot add an empty service to a server
at Server.addService (/Users/<user>/src/cloud-grpc/start/node_modules/grpc/src/node/src/server.js:735:11)
at Server.addProtoService (/Users/<user>/src/cloud-grpc/start/node_modules/grpc/src/node/src/server.js:786:8)
at Object.<anonymous> (/Users/<user>/src/cloud-grpc/start/server.js:7:8)
at Module._compile (module.js:571:32)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:488:32)
at tryModuleLoad (module.js:447:12)
at Function.Module._load (module.js:439:3)
at Module.runMain (module.js:605:10)
at run (bootstrap_node.js:418:7)
It looks like I can ignore this one and keep going through the tutorial, but thought I'd open this so you're aware of this issue too. I think I'll stop here though, and hopefully you can take care of any other updates that are required so users can get through the tutorial smoothly. Thanks!
/cc @MakMukhi
I just started the "Building a gRPC service with Node.js" codelab and got up to the "go run client.go" step, but it fails with
# _/Users/<user>/src/cloud-grpc/start/books
books/books.pb.go:107: undefined: grpc.SupportPackageIsVersion3
I'm new to this stack but based on a quick search it looks like grpc/grpc-go#1002 is the issue?
Based on the Proto file, the List
service states that it returns a list of books, which when received by the client would be of the format:
{ books: [] }
. But the statement in server.js
block directly sends the books array to the callback. Hence the client will not receive anything.
It should rather be sent as an object as follows: {books}
or {books: books}
The link of the page where the issue is: https://codelabs.developers.google.com/codelabs/cloud-grpc/index.html#4
I'm running on the cloud shell client. Step 4 says "Now, from the project directory, run the command-line client with no arguments (go run client.go) to view the available commands:". It doesn't say what it means by the "project directory" but assuming that's the top level dir (cloud-grcp) this command fails because there's no client. go in this dir.
I tried running it in the 'start' directory, but that fails with these errors:
marccohen@arched-history-136923:~/cloud-grpc/start$ go run client.go
books/books.pb.go:278: cannot use _BookService_List_Handler (type func(interface {}, context.Context, func(interfa
ce {}) error) (interface {}, error)) as type grpc.methodHandler in field value
books/books.pb.go:282: cannot use _BookService_Insert_Handler (type func(interface {}, context.Context, func(inter
face {}) error) (interface {}, error)) as type grpc.methodHandler in field value
books/books.pb.go:286: cannot use _BookService_Get_Handler (type func(interface {}, context.Context, func(interfac
e {}) error) (interface {}, error)) as type grpc.methodHandler in field value
books/books.pb.go:290: cannot use _BookService_Delete_Handler (type func(interface {}, context.Context, func(inter
face {}) error) (interface {}, error)) as type grpc.methodHandler in field value
Hi,
with grpc 1.0.1 you should use grpc.credentials.createInsecure()
instead of grpc.Credentials.createInsecure()
On https://codelabs.developers.google.com/codelabs/cloud-grpc/index.html?index=..%2F..%2Findex#8 one of the excerpts of client.js includes
var client = new booksProto.books.BookService('127.0.0.1:50051',
grpc.Credentials.createInsecure());
This causes
/Users/<user>/src/cloud-grpc/start/client.js:6
grpc.Credentials.createInsecure());
^
TypeError: Cannot read property 'createInsecure' of undefined
Replacing grpc.Credentials
with grpc.credentials
fixes this.
https://codelabs.developers.google.com/codelabs/cloud-grpc/index.html#2 currently says
To run the sample application, the following dependencies are required:
- Git
- Node.js
However, if you have the latest major version of Node, v7, you will hit an error installing the grpc npm package: grpc/grpc#8495 (comment)
GCP cloud shells currently come with Node 6.9 installed, but many users following the codelab from their own machines may have the latest Node installed, like I did. (e.g. Mac Homebrew users who've updated anytime since Node 7 came out will hit this.)
when issuing command "node server.js" I receive the following error:
Error: Parse error at line 11: illegal field rule: int32
at Parser.ProtoBuf.DotProto.ParserPrototype._parseMessage (/home/ilsorrisodellagioconda/cloud-grpc/start/node_modules/protobufjs/dist/protobuf.js:1117:31)
at Parser.ProtoBuf.DotProto.ParserPrototype.parse (/home/ilsorrisodellagioconda/cloud-grpc/start/node_modules/protobufjs/dist/protobuf.js:762:34)
at Function.ProtoBuf.DotProto.Parser.parse (/home/ilsorrisodellagioconda/cloud-grpc/start/node_modules/protobufjs/dist/protobuf.js:797:39)
at Object.ProtoBuf.loadProto (/home/ilsorrisodellagioconda/cloud-grpc/start/node_modules/protobufjs/dist/protobuf.js:5128:59)
at Object.ProtoBuf.loadProtoFile (/home/ilsorrisodellagioconda/cloud-grpc/start/node_modules/protobufjs/dist/protobuf.js:5174:52)
at Object.load (/home/ilsorrisodellagioconda/cloud-grpc/start/node_modules/grpc/index.js:135:26)
at Object.deprecated [as load] (internal/util.js:66:15)
at Object. (/home/ilsorrisodellagioconda/cloud-grpc/start/server.js:3:23)
at Module._compile (internal/modules/cjs/loader.js:689:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
Hey,
We recently updated the grpc code and the protoc generator thereby rendering grpc.SupportPackageIsVersion3 obsolete. This will cause compile-time problems. Regenerating books.pb.go should work.
Under books dir run: protoc -I . books.proto --go_out=plugins=grpc:.
Thanks
the fourth and fifth links in step 3 produce 404s
After running "go run client.go" as requested, output is:
books/books.pb.go:107: undefined: grpc.SupportPackageIsVersion3
Current dir: "~/cloud-grpc/start"
"go get google.golang.org/grpc" in previous step did not return nothing, assumed ok.
Как седлать gRPC клиент с помощью Node.js
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.