Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
311 views
in Technique[技术] by (71.8m points)

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

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

question from:https://stackoverflow.com/questions/65925662/grpc-js-angular-ngx-grpc-stream-stops-receiving-messages-after-4-received

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...