fix(coap): fix the issue the connection with same clientid is not discarded
This commit is contained in:
parent
f06ec6baaa
commit
a564670863
|
@ -111,12 +111,12 @@ init({ClientId, Username, Password, Channel}) ->
|
|||
_ = run_hooks('client.connect', [conninfo(State0)], undefined),
|
||||
case emqx_access_control:authenticate(clientinfo(State0)) of
|
||||
{ok, _AuthResult} ->
|
||||
ok = emqx_cm:discard_session(ClientId),
|
||||
|
||||
_ = run_hooks('client.connack', [conninfo(State0), success], undefined),
|
||||
|
||||
State = State0#state{connected_at = erlang:system_time(millisecond)},
|
||||
|
||||
%% TODO: Evict same clientid on other node??
|
||||
|
||||
run_hooks('client.connected', [clientinfo(State), conninfo(State)]),
|
||||
|
||||
erlang:send_after(?ALIVE_INTERVAL, self(), check_alive),
|
||||
|
@ -186,6 +186,11 @@ handle_info({shutdown, conflict, {ClientId, NewPid}}, State) ->
|
|||
?LOG(warning, "clientid '~s' conflict with ~p", [ClientId, NewPid]),
|
||||
{stop, {shutdown, conflict}, State};
|
||||
|
||||
handle_info(discard, State) ->
|
||||
?LOG(warning, "the connection is discarded. " ++
|
||||
"possibly there is another client with the same clientid", []),
|
||||
{stop, {shutdown, discarded}, State};
|
||||
|
||||
handle_info(kick, State) ->
|
||||
?LOG(info, "Kicked", []),
|
||||
{stop, {shutdown, kick}, State};
|
||||
|
|
Loading…
Reference in New Issue