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

gRPC streaming keepAlive doesn't work with docker swarm #838

Closed
npuichigo opened this issue Jan 6, 2019 · 4 comments
Closed

gRPC streaming keepAlive doesn't work with docker swarm #838

npuichigo opened this issue Jan 6, 2019 · 4 comments

Comments

@npuichigo
Copy link

In a swarm setup using overlay networks, idle connections between grpc-gateway and backend service will end up in a broken state after 15 minutes. (moby/moby#31208)

So I tried the following two ways. Firstly, I set net.ipv4.tcp_keepalive_time to less than 900 seconds, to make sure the TCP connection between grpc-gateway and IPVS doesn't expire. Secondly, I configured grpc.WithKeepaliveParams to set the ping time interval to 30 seconds. However, neither method works.

Is there anyway to configure grpc-gateway to support docker swarm?

@johanbrandhorst
Copy link
Collaborator

How did you configure the KeepaliveParams? The gRPC-Gateway uses a gRPC client to talk to the backend so there is not much we can do in terms of changing the gateway. The parameters must be specified to the Dial call. If that's not working, I'm afraid you will have to continue debugging your network setup.

I'm going to close this as it is a docker swarm issue with a gRPC client workaround. Please let me know if you want me to clarify anything.

@npuichigo
Copy link
Author

Thank you for your reply. I configure the KeepaliveParams like this, so I'm sure the parameters are passed to the Dial call.

ctx := context.Background()
        ctx, cancel := context.WithCancel(ctx)
        defer cancel()

        mux := runtime.NewServeMux()
        opts := []grpc.DialOption{
                grpc.WithInsecure(),
                grpc.WithKeepaliveParams(keepalive.ClientParameters{
                        Time:                30 * time.Second,
                        Timeout:             20 * time.Second,
                        PermitWithoutStream: true,
                }),
        }
        err := gw.RegisterMyHandlerFromEndpoint(ctx, mux, *echoEndpoint, opts)

@johanbrandhorst
Copy link
Collaborator

johanbrandhorst commented Jan 6, 2019

That looks correct, but unless there's a bug with the gateway not using the parameters in the call to gRPC.Dial, I don't see what we could do to help you. Can you investigate whether the keep alive is being used in the gRPC library?

@npuichigo
Copy link
Author

Okay, I'll check it. Thanks.

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