Skip to content
This repository has been archived by the owner on Apr 14, 2023. It is now read-only.

0.7.X changes server keep alive semantics in client #167

Closed
NeoPhi opened this issue Jun 6, 2017 · 9 comments
Closed

0.7.X changes server keep alive semantics in client #167

NeoPhi opened this issue Jun 6, 2017 · 9 comments

Comments

@NeoPhi
Copy link
Contributor

NeoPhi commented Jun 6, 2017

The SubscriptionClient document currently includes: timeout?: number : how long the client should wait in ms for a subscription to be started (default 5000 ms). However this is not how the parameter is being used. Instead this timeout is being used in the GQL_CONNECTION_KEEP_ALIVE handler to close the client to server connection if a server keep alive message is not received in that time. As implemented it feels like this is more of an idleTimeout. Additionally in previous versions the server sent keep alive were used to keep the underlying network connection open for long lived but infrequent subscriptions. Given our default server configuration this is also a parameter we will have to override in GraphiQL to ensure it doesn't close based on the default 5 second timeout.

@mistic
Copy link
Contributor

mistic commented Jun 9, 2017

good catch @NeoPhi!

@sorenbs
Copy link

sorenbs commented Jun 11, 2017

At Graphcool we send the keep-alive message at 30 second intervals which in almost all cases is enough to keep the underlying connection open. As it stands the client with default configuration disconnects 5 seconds after the first keep-alive message arrives.

From the Apollo Slack subscriptions channel:

Is there any specific reason for decreasing the default keep-alive interval to 5 seconds? That is much lower than what I am used to from other systems. Either we have to change our server to send ka messages every 2 seconds (to account for network latency), the keep-alive logic in Apollo has to be much more lenient towards missed ka messages or the default interval in the client has to be increased to something more reasonable (say, 30 seconds)

@helfer
Copy link
Contributor

helfer commented Jun 11, 2017

@sorenbs 5s sounds too low for me too. But just to check: it's the server that's sending the keepalive message here and the client that disconnects if it doesn't receive it? Shouldn't the client instead be the one that says when it wants the connection to stay alive? Presumably the server shouldn't care if the client wants to disconnect (unless it wastes resources by reconnecting right after that)?

@sorenbs
Copy link

sorenbs commented Jun 12, 2017

In our implementation the server is sending the ka message every 10 seconds no matter what the client does. This is simply to keep the connection open. The client is free to disconnect at any time, either by closing the connection or sending the disconnect message.

As I understand the current client implementation, it by default keeps the connection open forever. Then, when it receives the first ka message, it sets a timer for the specified timeout (default 5 sec) and sends the close connection message if a new ka message is not received before that time.

I'm not sure this client behaviour makes the most sense, but given this behaviour, I would like to see the default timeout increased.

@dotansimha
Copy link
Contributor

I see. do you have another idea for implementing the timeout feature?

I think that the current implementation let the client decide how to behave with the server, and use the keep-alive as it needs.

I agree on the 5s issue, and I think it should be higher to avoid disconnections. Do you think that 10s is high enough or we should increase it?

@sorenbs

@sorenbs
Copy link

sorenbs commented Jun 12, 2017

@dotansimha
Copy link
Contributor

dotansimha commented Jun 12, 2017

@sorenbs we changed it to 30s and @Urigo will release a new version of the transport soon :)

@sorenbs
Copy link

sorenbs commented Jun 12, 2017

Thanks all!

@Urigo
Copy link
Contributor

Urigo commented Jun 12, 2017

released in 0.7.2

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

No branches or pull requests

6 participants