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

Suppress server log message when EOF without receiving data for preface #1052

Merged
merged 3 commits into from
May 22, 2017

Conversation

dbudworth
Copy link
Contributor

When using a TCP load balancer (ie: AWS ELB), they do health checks by simply opening a connection to your port and then closing it.

Just to test if you can accept a connection.

Currently, this causes a log message of:

transport: http2Server.HandleStreams failed to receive the preface from client: EOF

This change suppresses that log message if, and only if, no bytes were received.

Basically, it allows a GRPC server to be used behind a simple TCP load balancer without spamming your logs.

@MakMukhi
Copy link
Contributor

@menghanl is already working on adding different levels to logging. This should be taken care of there. Menghan can confirm further when he's back.

@dbudworth
Copy link
Contributor Author

@menghanl Any chance your changes are going in soon? I have to keep moving the patch forward when I pull due to current code being super-noisy when used behind a tcp balancer.

@menghanl
Copy link
Contributor

menghanl commented Feb 7, 2017

The first step (#922) should be done by the end of this week.
After that, we will need another PR to change the logging levels.

grpclog.Printf("transport: http2Server.HandleStreams failed to receive the preface from client: %v", err)
if n, err := io.ReadFull(t.conn, preface); err != nil {
// Only log if it isn't a simple tcp accept check (ie: tcp balancer doing open/close socket)
if n > 0 || err != io.EOF {
Copy link
Contributor

@menghanl menghanl May 19, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's just need to check io.EOF here. If n>0, err will be ErrUnexpectedEOF.

From the doc of ReadFull:

The error is EOF only if no bytes were read.
If an EOF happens after reading some but not all the bytes,
ReadFull returns ErrUnexpectedEOF.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

makes sense, updated...

Copy link
Contributor

@menghanl menghanl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix.
LGTM.

@menghanl menghanl merged commit 79f73d6 into grpc:master May 22, 2017
@lock lock bot locked as resolved and limited conversation to collaborators Jan 19, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants