gRPC-js + Angular ngx-grpc - Stream stops receiving messages after 4 received

653 views Asked by At

I have a grpc-js server setup with a rpc method called getUsers(). When making the call from the client, I only receive 4 of the messages back, despite there being 6 sent.

Here's the client method:

const client = new UsersClient(environment.rpcHost);
    const params = new CMSQuery();
    client.getUsers(params).on('data', (message: User) => {
      const obj = message.toObject();
      console.log(`${obj.name} received`);
      this.users.push(obj);
    }).on('end', () => {
      console.log('End of request');
    });

And here's the server method:

    async getUsers(call: grpc.ServerWritableStream<CMSQuery, User>): Promise<any> {
        const params = call.request.toObject();
        this.collection.find({}).forEach(user => {
            const message = protoFromObject(User, user);
            call.write(message);
            console.log(`${user.name} sent`);
        }).finally(() => {
            console.log('Closing request');
            call.end();
        });
    }

The server has the following console output:

User1 sent
User2 sent
User3 sent
User4 sent
User5 sent
User6 sent
Closing Request

And yet the client only has the following console output:

User1 received
User2 received
User3 received
User4 received
End of request

Are there any obvious things that would cause this? Some sort of timeout? Can anyone give me some pointers as to where I should be looking as I'm really stuck at the moment.

Thanks

0

There are 0 answers