Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move SockStats to process dictionary for fix keepalive checking #127

Merged
merged 7 commits into from Jun 19, 2019

Conversation

@tradingtrace
Copy link
Contributor

tradingtrace commented Jun 18, 2019

Move the SockStates to the process dictionary just like emqx_ws_channel.erlto fix the issue: emqx/emqx#2622

I think the variable SockStates is bound to the fun closure and passed into emqx:keepalive:start/3. Every time the function emqx_keepalive:check/1 uses the same SockStates, which causes check error and shuts down the connection(keepalive_timeout).

handle_event(info, {keepalive, start, Interval}, _StateName,
StateData = #state{keepalive = undefined, sock_stats = SockStats}) ->
?LOG(debug, "Keepalive at the interval of ~p seconds", [Interval], StateData),
StatFun = fun() ->
case maps:get(recv_oct, SockStats, undefined) of
undefined ->
{error, undefined};
StatVal ->
{ok, StatVal}
end
end,
case emqx_keepalive:start(StatFun, Interval, {keepalive, check}) of
{ok, KeepAlive} ->
{keep_state, StateData#state{keepalive = KeepAlive}};
{error, Reason} ->
?LOG(warning, "Keepalive error - ~p", [Reason], StateData),
shutdown(Reason, StateData)
end;

turtleDeng and others added 5 commits May 27, 2019
Auto-pull-request-by-2019-05-27
Enlarge duration
@gilbertwong96 gilbertwong96 self-assigned this Jun 19, 2019
@gilbertwong96 gilbertwong96 changed the base branch from master to develop Jun 19, 2019
@gilbertwong96 gilbertwong96 merged commit 832d352 into emqx:develop Jun 19, 2019
1 check passed
1 check passed
continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.