Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion big_tests/tests/mod_ping_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ check_connection(_, Client) ->
true = escalus_connection:is_connected(Client).

wait_for_ping_req(Alice) ->
PingReq = escalus_client:wait_for_stanza(Alice, timer:seconds(10)),
PingReq = escalus_client:wait_for_stanza(Alice, ping_interval() + timer:seconds(1)),

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test change makes the issue visible in the test results. I am not sure how stable that timing would be in CI but locally the tests were stable. If there are timing flakiness concerns, let me know and I can look for other solutions.

escalus:assert(is_iq_get, PingReq),
<<"urn:xmpp:ping">> = exml_query:path(PingReq, [{element, <<"ping">>},
{attr, <<"xmlns">>}]),
Expand Down
7 changes: 1 addition & 6 deletions src/mod_ping.erl
Original file line number Diff line number Diff line change
Expand Up @@ -173,15 +173,10 @@ determine_action(<<"error">>) ->
mongoose_c2s_hooks:result().
user_send_packet(Acc, _Params, #{host_type := HostType}) ->
Interval = gen_mod:get_module_opt(HostType, ?MODULE, ping_interval),
Action = {{timeout, ping}, Interval, fun ping_c2s_handler/2},
Action = {{timeout, send_ping}, Interval, fun ping_c2s_handler/2},
{ok, mongoose_c2s_acc:to_acc(Acc, actions, Action)}.

-spec ping_c2s_handler(atom(), mongoose_c2s:data()) -> mongoose_c2s_acc:t().
ping_c2s_handler(ping, StateData) ->
HostType = mongoose_c2s:get_host_type(StateData),
Interval = gen_mod:get_module_opt(HostType, ?MODULE, ping_req_timeout),
Actions = [{{timeout, send_ping}, Interval, fun ping_c2s_handler/2}],
mongoose_c2s_acc:new(#{actions => Actions});
ping_c2s_handler(send_ping, StateData) ->
PingId = mongoose_bin:gen_from_crypto(),
IQ = ping_get(PingId),
Expand Down