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

Doesn't work with grpc-go's hello world example #82

Closed
MakotoE opened this issue Dec 12, 2020 · 2 comments
Closed

Doesn't work with grpc-go's hello world example #82

MakotoE opened this issue Dec 12, 2020 · 2 comments

Comments

@MakotoE
Copy link

MakotoE commented Dec 12, 2020

If I change https://github.com/grpc/grpc-go/blob/81b95b1854d7caf3cc21aed316fc222e1749cf31/examples/helloworld/greeter_server/main.go#L53 to:

m := cmux.New(lis)
go func() {
	if err := s.Serve(m.Match(cmux.Any())); err != nil {
		log.Fatalf("failed to serve: %v", err)
	}
}()
m.Serve()

This works as expected. The client side prints 2020/12/12 09:37:44 Greeting: Hello world. But if I add the content-type matcher,

m := cmux.New(lis)
go func() {
	if err := s.Serve(m.Match(cmux.HTTP2HeaderField("content-type", "application/grpc"))); err != nil {
		log.Fatalf("failed to serve: %v", err)
	}
}()
m.Serve()

The client cannot connect and blocks forever. In this switch

switch f := f.(type) {
I see that the case *http2.SettingsFrame: is being taken but not case *http2.ContinuationFrame: or case *http2.HeadersFrame: and I am guessing either of those two branches are supposed to be taken. Unit tests in this repo are passing. I'm not sure what is wrong.

@MakotoE
Copy link
Author

MakotoE commented Dec 12, 2020

I just got it to work using HTTP2MatchHeaderFieldSendSettings. I'm not sure why this work while the previous method didn't.

m := cmux.New(lis)
go func() {
	if err := s.Serve(m.MatchWithWriters(cmux.HTTP2MatchHeaderFieldSendSettings("content-type", "application/grpc"))); err != nil {
		log.Fatalf("failed to serve: %v", err)
	}
}()
m.Serve()

@MakotoE MakotoE closed this as completed Dec 12, 2020
@zepatrik
Copy link

I had the same problem. I always got a Method: PRI ... request that the server could not handle. Maybe something in the go-grpc client changed recently? Anyway, using cmux.HTTP2MatchHeaderFieldSendSettings works.

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

No branches or pull requests

2 participants