aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/node
diff options
context:
space:
mode:
authorGravatar Craig Tiller <ctiller@google.com>2017-07-05 08:37:09 -0700
committerGravatar Craig Tiller <ctiller@google.com>2017-07-05 08:37:09 -0700
commita1a3f363ee0309bdfbcdf919ab57468e3522731a (patch)
treea4d755c6b8512f47771a23ae8255ccb567391359 /src/node
parentf95873e67632c2b7c323c6613b5e23cae60ecf17 (diff)
parent7405347cd848f27067b9ce3c029325799ebaa888 (diff)
Merge github.com:grpc/grpc into optimize_for
Diffstat (limited to 'src/node')
-rw-r--r--src/node/src/grpc_extension.js7
-rw-r--r--src/node/test/surface_test.js47
2 files changed, 54 insertions, 0 deletions
diff --git a/src/node/src/grpc_extension.js b/src/node/src/grpc_extension.js
index c13bf819de..af43eacad2 100644
--- a/src/node/src/grpc_extension.js
+++ b/src/node/src/grpc_extension.js
@@ -16,6 +16,13 @@
*
*/
+/**
+ * @module
+ * @private
+ */
+
+'use strict';
+
var binary = require('node-pre-gyp/lib/pre-binding');
var path = require('path');
var binding_path =
diff --git a/src/node/test/surface_test.js b/src/node/test/surface_test.js
index 8c750ea484..d58d18057e 100644
--- a/src/node/test/surface_test.js
+++ b/src/node/test/surface_test.js
@@ -1363,3 +1363,50 @@ describe('Cancelling surface client', function() {
call.cancel();
});
});
+describe('Client reconnect', function() {
+ var server;
+ var Client;
+ var client;
+ var port;
+ beforeEach(function() {
+ var test_proto = ProtoBuf.loadProtoFile(__dirname + '/echo_service.proto');
+ var echo_service = test_proto.lookup('EchoService');
+ Client = grpc.loadObject(echo_service);
+ server = new grpc.Server();
+ server.addService(Client.service, {
+ echo: function(call, callback) {
+ callback(null, call.request);
+ }
+ });
+ port = server.bind('localhost:0', server_insecure_creds);
+ client = new Client('localhost:' + port, grpc.credentials.createInsecure());
+ server.start();
+ });
+ afterEach(function() {
+ server.forceShutdown();
+ });
+ it('should reconnect after server restart', function(done) {
+ client.echo({value: 'test value', value2: 3}, function(error, response) {
+ assert.ifError(error);
+ assert.deepEqual(response, {value: 'test value', value2: 3});
+ server.tryShutdown(function() {
+ server = new grpc.Server();
+ server.addService(Client.service, {
+ echo: function(call, callback) {
+ callback(null, call.request);
+ }
+ });
+ server.bind('localhost:' + port, server_insecure_creds);
+ server.start();
+ client.echo(undefined, function(error, response) {
+ if (error) {
+ console.log(error);
+ }
+ assert.ifError(error);
+ assert.deepEqual(response, {value: '', value2: 0});
+ done();
+ });
+ });
+ });
+ });
+});