Client receives out-of-order stream

67 views
Skip to first unread message

Xiaokun Luan

unread,
Mar 1, 2024, 8:55:59 AMMar 1
to grpc.io
Hi all, I have a server implemented in Scala using zio-grpc, and a client in Python.

I found that sometimes the stream received by the client is out of order. For example, the sequence of data sent by the server is [1, 2, 3, 4, 5], but those received by the client are [1, 2, 4, 3, 5]. Though I'm new to grpc, I don't think this is an expected behavior.

According to my testing results, this happens rarely, and usually only one or two pairs of adjacent items are swapped. I have checked and made sure that the sequence is scrambled after sending, so the error should not be on the server side.

I'm still working on a minimal example, and I cannot help wondering has anyone had a similar situation? Any things that could go wrong? Or maybe I didn't do it in the right way? Any help or advice would be appreciated.

Below is some relevant information:
OS: Ubuntu 22.04
Python version: 3.10.13
grpcio version: 1.51.1  (couldn't find 1.50.1)
grpcio-tools version: 1.51.1
grpc version: 4.25.3
Scala version: 2.13.13
grpc-netty version: 1.50.1

apo...@google.com

unread,
Mar 12, 2024, 1:11:52 PMMar 12
to grpc.io
Are you sending this sequence of data on the same stream? Using a bidirectional or server-streaming RPC, for example?

This should indeed not be happening. Without knowing more, I would guess that the data is being accidentally written to the stream in a bad orders, when this happens. Otherwise, a reproduction may help.

Xiaokun Luan

unread,
Mar 12, 2024, 9:54:04 PMMar 12
to grpc.io
Thanks for your reply, here is a minimal example: https://drive.google.com/file/d/1Eew2sOhjSt2tCBEupE1glo6PALYkB0t1/view

Running this example on my machine gives me something like:

Expected: [0, 1, 2, ...]
Got:           [0, 1, 2, ...]
Diff:           [x, y, ...]

yas...@google.com

unread,
Mar 18, 2024, 10:09:19 PMMar 18
to grpc.io
This might be something to raise with maintainers of https://github.com/scalapb/zio-grpc. I'm not sure if they monitor this forum.
Reply all
Reply to author
Forward
0 new messages