From da4738137cabe7ed5dbfd6c9f0bf4539d587b3ad Mon Sep 17 00:00:00 2001 From: reggiemcdonald Date: Tue, 28 Jul 2020 20:28:55 +0000 Subject: [PATCH] fix: require grpc-js instead of grpc in grpc-js example Signed-off-by: reggiemcdonald --- examples/grpc-js/helloworld_grpc_pb.js | 2 +- examples/grpc-js/server.js | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/examples/grpc-js/helloworld_grpc_pb.js b/examples/grpc-js/helloworld_grpc_pb.js index 1e39a0f46a..d96cae46c7 100644 --- a/examples/grpc-js/helloworld_grpc_pb.js +++ b/examples/grpc-js/helloworld_grpc_pb.js @@ -18,7 +18,7 @@ 'use strict'; -const grpc = require('grpc'); +const grpc = require('@grpc/grpc-js'); const helloworld_pb = require('./helloworld_pb.js'); function serialize_HelloReply(arg) { diff --git a/examples/grpc-js/server.js b/examples/grpc-js/server.js index 1b9d533172..1d71833ff1 100644 --- a/examples/grpc-js/server.js +++ b/examples/grpc-js/server.js @@ -2,7 +2,7 @@ const tracer = require('./tracer')(('example-grpc-server')); // eslint-disable-next-line import/order -const grpc = require('grpc'); +const grpc = require('@grpc/grpc-js'); const messages = require('./helloworld_pb'); const services = require('./helloworld_grpc_pb'); @@ -14,9 +14,10 @@ function startServer() { // Creates a server const server = new grpc.Server(); server.addService(services.GreeterService, { sayHello }); - server.bind(`0.0.0.0:${PORT}`, grpc.ServerCredentials.createInsecure()); - console.log(`binding server on 0.0.0.0:${PORT}`); - server.start(); + server.bindAsync(`0.0.0.0:${PORT}`, grpc.ServerCredentials.createInsecure(), () => { + console.log(`binding server on 0.0.0.0:${PORT}`); + server.start(); + }); } function sayHello(call, callback) {