I'm trying to stream a nodejs child process output via grpc but keep on getting empty result.
Given my proto file.
syntax = "proto3";
package servicePackage;
service Mobile {
rpc sign(Empty) returns (stream SHA256Info);
}
message Empty {}
message SHA256Info {
string signature = 1;
}
And my grpc server code
function sign(call, callback) {
const cp = require('child_process');
var signature = "";
let child = cp.exec('keytool -list -v -keystore android.keystore -alias android -storepass hardcodedstorepass -keypass hardcodedkeypass', { cwd: "./output" });
child.on('exit', function (code, signal) {
console.log('process exited with ' + `code ${code} and signal ${signal}`);
call.end();
});
child.stdout.on('data', (data) => {
if (data.includes("Certificate fingerprints:")) {
var sig = data.substring(data.indexOf("SHA256:"));
signature = sig;
call.write({"SHA256Info": signature});
}
});
child.stderr.on('data', (data) => {
//console.error(`stderr:\n${data}`);
});
}
And my grpc client code
const call = client.sign({});
call.on("data", signature => {
console.log("STREAMED data => " + JSON.stringify(signature));
})
call.on("end", e => console.log("server done!"));
All I get is as a result is this:
{} //<------ empty result
server done!
My question is what am I doing wrong that is causing an empty result?