Skip to content

Commit

Permalink
Merge pull request #4363 from esl/rename_c2s_state_timeout
Browse files Browse the repository at this point in the history
Rename `c2s_state_timeout` option to `state_timeout`
  • Loading branch information
JanuszJakubiec authored Aug 28, 2024
2 parents 3f2f4f8 + 2337813 commit ed4ec1d
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 12 deletions.
4 changes: 2 additions & 2 deletions doc/listeners/listen-c2s.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ The value of the access rule needs to be either the shaper name or the string `"

Maximum number of open connections. This is a *soft limit* according to the [Ranch](https://ninenines.eu/docs/en/ranch/2.1/manual/ranch) documentation.

### `listen.c2s.c2s_state_timeout`
### `listen.c2s.state_timeout`
* **Syntax:** non-negative integer or the string `"infinity"`
* **Default:** `5000`
* **Example:** `c2s_state_timeout = 10_000`
* **Example:** `state_timeout = 10_000`

Timeout value (in milliseconds) used by the C2S state machine when waiting for the connecting client to respond during stream negotiation and SASL authentication. After the timeout the server responds with the `connection-timeout` stream error and closes the connection.

Expand Down
4 changes: 2 additions & 2 deletions doc/listeners/listen-http.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,11 @@ Maximum allowed incoming stanza size in bytes.

### `listen.http.handlers.mod_websockets.c2s_state_timeout`

Same as the [C2S option](listen-c2s.md#listenc2sc2s_state_timeout)
Same as the [C2S option](listen-c2s.md#listenc2sstate_timeout).

### `listen.http.handlers.mod_websockets.backwards_compatible_session`

Same as the [C2S option](listen-c2s.md#listenc2sbackwards_compatible_session)
Same as the [C2S option](listen-c2s.md#listenc2sbackwards_compatible_session).

## Handler types: GraphQL API - `mongoose_graphql_handler`

Expand Down
2 changes: 1 addition & 1 deletion doc/migrations/6.0.0_6.1.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ With the new implementation of the client-to-server (C2S) state machine, `mongoo
* Support for [`listen.http.handlers.mod_websockets.service`] has been removed, the component connection over WebSockets did not correspond to any XEP/RFC, and neither it was properly described anywhere in the MIM documentation. It was present in the default configuration file, and **you need to delete it** from your listener configuration unless you have already done so.
* The `max_fsm_queue` option is no longer supported for C2S listeners. It is incompatible with the new `gen_statem` state machine, and if you need to limit incoming traffic, you should use [traffic shapers](../../configuration/shaper) instead. You need to remove this option from your C2S configuration if you are using it.
* The default value of the [`backlog`](../configuration/listen.md#listenbacklog) option for all XMPP listeners has been increased from 100 to 1024 for performance reasons.
* You might be interested in the new C2S listener options: [`max_connections`](../listeners/listen-c2s.md#listenc2smax_connections), [`c2s_state_timeout`](../listeners/listen-c2s.md#listenc2sc2s_state_timeout), [`reuse_port`](../listeners/listen-c2s.md#listenc2sreuse_port) and [`backwards_compatible_session`](../listeners/listen-c2s.md#listenc2sbackwards_compatible_session). The first two options can be set for [websockets](../listeners/listen-http.md#handler-types-websockets-mod_websockets) as well.
* You might be interested in the new C2S listener options: [`max_connections`](../listeners/listen-c2s.md#listenc2smax_connections), [`c2s_state_timeout`](../listeners/listen-c2s.md#listenc2sstate_timeout), [`reuse_port`](../listeners/listen-c2s.md#listenc2sreuse_port) and [`backwards_compatible_session`](../listeners/listen-c2s.md#listenc2sbackwards_compatible_session). The first two options can be set for [websockets](../listeners/listen-http.md#handler-types-websockets-mod_websockets) as well.

## Module configuration

Expand Down
4 changes: 4 additions & 0 deletions doc/migrations/6.2.1_x.x.x.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,7 @@

Hook names have been unified by removing the `_hook` prefix from the few hooks which used it,
e.g. `offline_message_hook` is now called `offline_message`. This change affects the hook metric names as well.

## Listener configuration

`listen.c2s.c2s_state_timeout` option has been renamed to [listen.c2s.state_timeout](../listeners/listen-c2s.md#listenc2sstate_timeout).
4 changes: 2 additions & 2 deletions src/c2s/mongoose_c2s.erl
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
-type listener_opts() :: #{shaper := atom(),
max_stanza_size := non_neg_integer(),
backwards_compatible_session := boolean(),
c2s_state_timeout := non_neg_integer(),
state_timeout := non_neg_integer(),
port := inet:port_number(),
ip_tuple := inet:ip_address(),
proto := tcp,
Expand Down Expand Up @@ -1027,7 +1027,7 @@ send_xml(#c2s_data{socket = Socket}, XmlElements) when is_list(XmlElements) ->

state_timeout(#c2s_data{listener_opts = LOpts}) ->
state_timeout(LOpts);
state_timeout(#{c2s_state_timeout := Timeout}) ->
state_timeout(#{state_timeout := Timeout}) ->
{state_timeout, Timeout, state_timeout_termination}.

-spec replace_resource(data(), binary()) -> data().
Expand Down
4 changes: 2 additions & 2 deletions src/config/mongoose_config_spec.erl
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ xmpp_listener_extra(<<"c2s">>) ->
validate = non_empty},
<<"max_connections">> => #option{type = int_or_infinity,
validate = positive},
<<"c2s_state_timeout">> => #option{type = int_or_infinity,
<<"state_timeout">> => #option{type = int_or_infinity,
validate = non_negative},
<<"reuse_port">> => #option{type = boolean},
<<"backwards_compatible_session">> => #option{type = boolean},
Expand All @@ -313,7 +313,7 @@ xmpp_listener_extra(<<"c2s">>) ->
defaults = #{<<"access">> => all,
<<"shaper">> => none,
<<"max_connections">> => infinity,
<<"c2s_state_timeout">> => 5000,
<<"state_timeout">> => 5000,
<<"reuse_port">> => false,
<<"backwards_compatible_session">> => true}
};
Expand Down
2 changes: 1 addition & 1 deletion src/mod_bosh_socket.erl
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ init([{HostType, Sid, Peer, PeerCert, ListenerOpts}]) ->
xml_socket => true,
max_stanza_size => 0,
hibernate_after => 0,
c2s_state_timeout => 5000,
state_timeout => 5000,
backwards_compatible_session => true,
proto => tcp},
{ok, C2SPid} = mongoose_c2s:start({?MODULE, BoshSocket, C2SOpts}, []),
Expand Down
2 changes: 1 addition & 1 deletion src/mod_websockets.erl
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ maybe_start_fsm([#xmlel{ name = <<"open">> }],
max_stanza_size => 0,
xml_socket => true,
hibernate_after => 0,
c2s_state_timeout => StateTimeout,
state_timeout => StateTimeout,
backwards_compatible_session => BackwardsCompatible,
port => Port, ip_tuple => IPTuple, proto => tcp},
do_start_fsm(Opts, State);
Expand Down
2 changes: 1 addition & 1 deletion test/common/config_parser_helper.erl
Original file line number Diff line number Diff line change
Expand Up @@ -1128,7 +1128,7 @@ default_config([listen, http, tls]) ->
default_config([listen, c2s]) ->
(common_xmpp_listener_config())#{module => mongoose_c2s_listener,
max_connections => infinity,
c2s_state_timeout => 5000,
state_timeout => 5000,
reuse_port => false,
backwards_compatible_session => true,
access => all,
Expand Down

0 comments on commit ed4ec1d

Please sign in to comment.