Skip to content

Bidirectional streaming not working when using Grpc.Net.Client.Web #1815

@hakito

Description

@hakito

What version of gRPC and what language are you using?

Grpc.Net.Client.Web 2.46.0
C#

What operating system (Linux, Windows,...) and version?

Windows 10 21H2

What runtime / compiler are you using (e.g. .NET Core SDK version dotnet --info)

Server: net6.0
Client: net462

What did you do?

I implemented a bidirectional streaming service using the GrpcWebHandler

service SampleService {
  rpc PingPong(stream google.protobuf.BytesValue) returns (stream google.protobuf.BytesValue) {}
}

The client sends a single request wich is handled by the server and waits for the response.

await pingPong.RequestStream.WriteAsync(new BytesValue() { Value = ByteString.CopyFromUtf8("Ping") });
await pingPong.ResponseStream.MoveNext();

The server awaits the stream from the client and returns a message

while (await requestStream.MoveNext())
{
    var buf = requestStream.Current;
    var msg = buf.Value.ToStringUtf8();
    await responseStream.WriteAsync(new BytesValue() { Value = ByteString.CopyFromUtf8($"You sent {msg} from session {session.GetString("Foo")}") });
}

What did you expect to see?

I expected a response from the server.

What did you see instead?

The client is stuck waiting endless for a response. The implementationon the server is not even called.

Anything else we should know about your project / environment?

It works properly when I either use grpc.core (wich is deprecated), or when I switch the clients target framework to net6 (without GrpcWebHandler).

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions