Closed sjkummer closed 4 years ago
I found a good solution for my GRPC problems with Nestjs.
For everyone wondering: You can ignore the poorly documented Nestjs method wrappers and use plain GRPC instead, e.g.:
@Client(grpcClientOptions)
private client: ClientGrpc;
const client = this.client.getClientByServiceName("MyService");
const method: ClientDuplexStream<Request, Response> = client["MyDuplexMethod"](metadata);
method.on('data', chunk => {
});
method.on('error', (e) => {
});
method.on('end', () => {
});
method.write(new Request());
Fixed + added docs + updated sample :) ref https://docs.nestjs.com/microservices/grpc#streaming-sample
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Bug Report
Current behavior
When creating GRPC duplex stream methods on client side, nestjs does not provide a way for the client to send messages to the server.
Input Code
Internally, nestjs creates a
ClientDuplexStream
object inside thecreateStreamServiceMethod
ofclient-grpc.ts
(namedcall
) but there is no way to access it. https://github.com/nestjs/nest/blob/master/packages/microservices/client/client-grpc.ts#L116After doing a hack and makeing the
ClientDuplexStream
accessable, messages can be successfully sent to the server. Therefore, the underlying GRPC-mechanisms are working fine.Expected behavior
The GRPC-Client declaration should ether return a
ClientDuplexStream
e.g.:or accepting upstream Observables, e.g.: