hyperium / tonic

A native gRPC client & server implementation with async/await support.
https://docs.rs/tonic
MIT License
9.76k stars 997 forks source link

Return stream after server response only #1381

Open rekby opened 1 year ago

rekby commented 1 year ago

Bug Report

Version

rekby@rekby-osx:~/p/y/ydb-rs-sdk|master⚡ ➤ cargo tree | grep tonic ├── tonic v0.8.2 └── tonic v0.8.2 () ├── tonic-build v0.8.0

Crates

tonic

Description

While tonic create bidirectional stream - it wait first server response before return response stream.

Tonic's implementation of server always return empty message with code 200 after init grpc stream, but some servers (in my case YDB server) not sent status code until first message. But the server wait init message from client.

It make impossible create empty streams and sent init response in usual way. Now workaround - create stream with initial message in input stream.

Other languages (go, python) allow to create stream without wait initial status response and work with same server good.

GRPC doc: https://grpc.io/docs/what-is-grpc/core-concepts/#bidirectional-streaming-rpc The server can choose to send back its initial metadata or wait for the client to start streaming messages.

declark1 commented 3 months ago

Also facing this issue. I set up a bidirectional stream with an empty input stream and the client.stream_method(input_stream).await call hangs and times out as the input stream doesn't contain any messages yet at this point.

Also seems related to https://github.com/hyperium/tonic/issues/515