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

Server Keep Alive Params aren't killing connections #2607

Closed
asad-awadia opened this issue Jan 30, 2019 · 3 comments
Closed

Server Keep Alive Params aren't killing connections #2607

asad-awadia opened this issue Jan 30, 2019 · 3 comments

Comments

@asad-awadia
Copy link

Please answer these questions before submitting your issue.

What version of gRPC are you using?

1.15

What version of Go are you using (go version)?

go1.11.1 darwin/amd64

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

Mac OS High Sierra 10.13.6

What did you do?

Start a gRPC Server using

s := grpc.NewServer(grpc.KeepaliveParams(keepalive.ServerParameters{
		MaxConnectionAge:time.Second,
		MaxConnectionIdle:time.Second,
		MaxConnectionAgeGrace:time.Second,
	}))

and then connect to it with a local client and print out state

conn, _ := grpc.Dial(":8888", grpc.WithInsecure(), grpc.WithDisableRetry())

	for {
		time.Sleep(2 * time.Second)
		fmt.Println(conn.GetState())
	}

What did you expect to see?

Expect for a an idle connection the connection to be shutdown i.e. the state in the for loop should change

What did you see instead?

The state continues to stay as READY

@menghanl
Copy link
Contributor

Can you turn on logs and see if the client stays READY all the time: https://github.com/grpc/grpc-go#how-to-turn-on-logging?

@asad-awadia
Copy link
Author

@menghanl

READY
INFO: 2019/01/31 09:31:20 transport: loopyWriter.run returning. connection error: desc = "transport is closing"
INFO: 2019/01/31 09:31:20 pickfirstBalancer: HandleSubConnStateChange: 0xc00012c010, TRANSIENT_FAILURE
INFO: 2019/01/31 09:31:20 pickfirstBalancer: HandleSubConnStateChange: 0xc00012c010, CONNECTING
INFO: 2019/01/31 09:31:20 pickfirstBalancer: HandleSubConnStateChange: 0xc00012c010, READY

I am assuming its reconnecting so quickly it goes back to READY immediately?

Is there a way to turn retries/reconnections off?

@menghanl
Copy link
Contributor

menghanl commented Jan 31, 2019

I am assuming its reconnecting so quickly it goes back to READY immediately?

Right. We do exponential backoff, and the first retry happens very fast (1 second initial backoff).

The backoff is also reset when a connection is created, which will happen in your test because server only closes connections after they are created for 1 second. So you will always see the initial 1 second backoff.

There's currently no way to stop reconnecting.
There's a pending issue to support IDLE: #1719, (also #1786), but we currently don't have time to work on that.

If you don't want to keep the idle connections, and know that you won't need it for some time, you can close the ClientConn and recreate it later. This will introduce some overhead though.

@lock lock bot locked as resolved and limited conversation to collaborators Jul 31, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants