Repository: graphql-rust/juniper (language: rust)

Issue:
juniper_graphql_ws silently closes the socket
**Describe the bug**
When running the latest `examples/warp_subscriptions` app locally the websocket silently dies after ~20 seconds. I suspect that there's an issue with the keepalive functionality but haven't been able to track it down. If `config.with_keep_alive_interval(0)` is used the socket stays open. If `config.with_keep_alive_interval(Duration::from_secs(15))` is used it also stays open, however if the default is left (30) or it's manually set to > 25 with `with_keep_alive_interval` the socket will die after a few seconds.

**To Reproduce**
Steps to reproduce the behavior:
1. Run the example app
1. Execute `subscription { users { id } }` in GraphiQL
1. After ~20 seconds the socket will disconnect

**Expected behavior**
The socket should remain open permanently. It would be nice if a log event was generated when the socket closes (crashes?).


Discussion / hints:
There is no default keepalive value for GraphQL clients, so it is up to you to set it for your particular use-case.

See this in the example:

https://github.com/graphql-rust/juniper/blob/45c16acc6e6dba9cf32e075d4516a9ab7c6fe780/examples/actix_subscriptions/src/main.rs#L101

We actually probably shouldn't even provide a default and make consumers specify it. Though if clients are all starting to default to the same value happy to take a patch.
Actually, reopening. I wonder if we are using just simple durations between keep alive pings instead of checking that we get pings in x second bucket intervals. 
(note there is a potential fence post / counting problem here on both sides)
It looks like `graphiql` uses https://github.com/apollographql/subscriptions-transport-ws under the hood. According to the readme the default is 30000 ms.

There is probably something wonky here where the playground is 20 secs but we need 15 to actually work. I wonder if we are sending it too late or the clients are starting to count too early?
For some reason it hadn't occurred to me that the client was closing the connection. It looks like this is just a simple mismatch between the juniper_graphql_ws crate's default of 30 seconds https://github.com/graphql-rust/juniper/blob/master/juniper_graphql_ws/src/lib.rs#L66 and the GraphQL Playground's default of 20 seconds https://github.com/prisma-labs/graphql-playground/blob/master/packages/graphql-playground-react/src/state/sessions/fetchingSagas.ts#L81

I guess this is still _sort_ of a bug but it's just a config change in the example. Would you like to see a PR that drops the example keepalive down to 15 seconds so it doesn't disconnect?
I'd take a PR to make the default 15 seconds, sounds like that will work for Graphiql and the playground!

Fix patch:
diff --git a/juniper_graphql_ws/src/lib.rs b/juniper_graphql_ws/src/lib.rs
index fbbb7565e..ab9faff5b 100644
--- a/juniper_graphql_ws/src/lib.rs
+++ b/juniper_graphql_ws/src/lib.rs
@@ -63,7 +63,7 @@ impl<CtxT> ConnectionConfig<CtxT> {
         Self {
             context,
             max_in_flight_operations: 0,
-            keep_alive_interval: Duration::from_secs(30),
+            keep_alive_interval: Duration::from_secs(15),
         }
     }
 


Test patch: