Skip to content

Commit

Permalink
Default keepalive to infinity for all protocols
Browse files Browse the repository at this point in the history
For HTTP/2 some servers are not fond of receiving pings,
especially if there's no stream at the time. (particularly
gRPC servers). This is an odd decision for sure. Rather
than trying to accomodate for their logic the ping is no
longer sent by default.

For Websocket sending a ping is a new feature in Gun 2.0
so I'm just being conservative there.
  • Loading branch information
essen committed Oct 7, 2020
1 parent 7d3dffd commit 556645d
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions doc/src/manual/gun.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ flow - see below::
The initial flow control value for all HTTP/2 streams.
By default flow control is disabled.

keepalive (5000)::
keepalive (infinity)::

Time between pings in milliseconds.

Expand Down Expand Up @@ -514,7 +514,7 @@ flow - see below::
The initial flow control value for the Websocket connection.
By default flow control is disabled.

keepalive (5000)::
keepalive (infinity)::

Time between pings in milliseconds.

Expand Down Expand Up @@ -559,7 +559,7 @@ when receiving a ping.
lowercased as well.
* *2.0*: Function `gun:headers/4,5` introduced.
* *2.0*: The `keepalive` option is now set to `infinity` by
default for the HTTP/1.1 protocol, disabling it.
default for all protocols. This means it is disabled.
* *2.0*: Websocket options `keepalive` and `silence_pings` introduced.
* *1.3*: Add the CONNECT destination's `protocols` option and
deprecate the previously introduced `protocol` option.
Expand Down
2 changes: 1 addition & 1 deletion src/gun_http2.erl
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ do_check_options([Opt={Name, _}|Opts]) ->
name() -> http2.
opts_name() -> http2_opts.
has_keepalive() -> true.
default_keepalive() -> 5000.
default_keepalive() -> infinity.

init(_ReplyTo, Socket, Transport, Opts0) ->
%% We have different defaults than the protocol in order
Expand Down
2 changes: 1 addition & 1 deletion src/gun_ws.erl
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ do_check_options([Opt|_]) ->
name() -> ws.
opts_name() -> ws_opts.
has_keepalive() -> true.
default_keepalive() -> 5000.
default_keepalive() -> infinity.

init(ReplyTo, Socket, Transport, #{stream_ref := StreamRef, headers := Headers,
extensions := Extensions, flow := InitialFlow, handler := Handler, opts := Opts}) ->
Expand Down

0 comments on commit 556645d

Please sign in to comment.