Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

After the streaming call ends, client response.tailer() returns empty #2656

Closed
YarBor opened this issue Apr 10, 2024 · 0 comments · Fixed by #2658
Closed

After the streaming call ends, client response.tailer() returns empty #2656

YarBor opened this issue Apr 10, 2024 · 0 comments · Fixed by #2658

Comments

@YarBor
Copy link
Contributor

YarBor commented Apr 10, 2024

Environment

  • Server: v3.1.1
  • Client: v3.1.1
  • Protocol: tri
  • Registry: -

Issue description

client-code

func testBidiStream(cli greet.GreetService) error {
	stream, err := cli.GreetStream(context.Background())
	if err != nil {
		return err
	}
	for i := 0; i < 10; i++ {
		if sendErr := stream.Send(&greet.GreetStreamRequest{Name: "triple"}); sendErr != nil {
			return err
		}
		_, err := stream.Recv()
		if err != nil {
			return err
		}
	}
	if err := stream.CloseRequest(); err != nil {
		return err
	}
	if err := stream.CloseResponse(); err != nil {
		return err
	}

	fmt.Printf("%v\n", stream.ResponseTrailer())
	return nil
}

server-code

func (srv *GreetTripleServer) GreetStream(ctx context.Context, stream greet.GreetService_GreetStreamServer) error {
	str, _ := json.MarshalIndent(ctx.Value(constant.AttachmentKey), "", "\t")
	fmt.Printf("%v\n", string(str))
	for {
		req, err := stream.Recv()
		if err != nil {
			if triple.IsEnded(err) {
				break
			}
			return fmt.Errorf("triple BidiStream recv error: %s", err)
		}
		if err := stream.Send(&greet.GreetStreamResponse{Greeting: req.Name}); err != nil {
			return fmt.Errorf("triple BidiStream send error: %s", err)
		}
	}
	stream.ResponseTrailer().Set("responeTrailerKey", strconv.Itoa(rand.Int()))
	stream.ResponseTrailer().Add("responeTrailerKey", strconv.Itoa(rand.Int()))
	return nil
}

是我的使用方式有问题吗

Logs

Click me to check logs
2024-04-10 19:12:50	INFO	logger/logging.go:42	URL specified explicitly tri://127.0.0.1:20000
2024-04-10 19:12:50	INFO	logger/logging.go:42	[TRIPLE Protocol] Refer service: tri://127.0.0.1:20000/greet.GreetService?app.version=&application=dubbo.io&async=false&bean.name=greet.GreetService&cluster=failover&config.tracing=&environment=&generic=&group=&interface=greet.GreetService&loadbalance=&metadata-type=local&module=sample&name=dubbo.io&organization=dubbo-go&owner=dubbo-go&peer=true&provided-by=&reference.filter=cshutdown&registry.role=0&release=dubbo-golang-3.2.0&remote.timestamp=&retries=&serialization=protobuf&side=consumer&sticky=false&timestamp=1712747570&version=
map[]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant