fix
This commit is contained in:
parent
a2af6feaca
commit
4e73d2a588
@ -107,23 +107,33 @@ handle_info({connect_reply, Reply}, State = #state{status = ?STATE_CONNECTING, t
|
||||
end;
|
||||
|
||||
handle_info({auth_reply, {ok, ReplyBin}}, State = #state{status = ?STATE_AUTH, transport_pid = TransportPid}) ->
|
||||
case message_pb:decode_msg(ReplyBin, auth_reply) of
|
||||
try message_pb:decode_msg(ReplyBin, auth_reply) of
|
||||
#auth_reply{code = 1, message = Message, repository_url = RepositoryUrl} ->
|
||||
efka_logger:debug("[efka_agent] auth failed, message: ~p, repository_url: ~p", [Message, RepositoryUrl]),
|
||||
lager:debug("[efka_agent] auth failed, message: ~p, repository_url: ~p", [Message, RepositoryUrl]),
|
||||
{noreply, State#state{status = ?STATE_ACTIVATED}};
|
||||
%% 主机在后台的授权未通过;此时agent不能推送数据给云端服务器,但是云端服务器可以推送命令给agent
|
||||
%% socket的连接状态需要维持
|
||||
#auth_reply{code = -1, message = Message} ->
|
||||
efka_logger:debug("[efka_agent] auth denied, message: ~p", [Message]),
|
||||
#auth_reply{code = -1, message = Message, repository_url = _} ->
|
||||
lager:debug("[efka_agent] auth denied, message: ~p", [Message]),
|
||||
{noreply, State#state{status = ?STATE_RESTRICTED}};
|
||||
#auth_reply{code = -2, message = Message} ->
|
||||
#auth_reply{code = -2, message = Message, repository_url = _} ->
|
||||
% 其他类型的错误,需要间隔时间重试
|
||||
efka_logger:debug("[efka_agent] auth failed, message: ~p", [Message]),
|
||||
efka_transport:stop(TransportPid),
|
||||
{noreply, State#state{transport_pid = undefined, status = ?STATE_DENIED}};
|
||||
_ ->
|
||||
% 其他类型的错误,需要间隔时间重试
|
||||
lager:debug("[efka_agent] auth failed, invalid message"),
|
||||
efka_transport:stop(TransportPid),
|
||||
{noreply, State#state{transport_pid = undefined, status = ?STATE_DENIED}}
|
||||
catch _:Reason ->
|
||||
% 其他类型的错误,需要间隔时间重试
|
||||
lager:debug("[efka_agent] auth decode bin get error: ~p", [Reason]),
|
||||
efka_transport:stop(TransportPid),
|
||||
{noreply, State#state{transport_pid = undefined, status = ?STATE_DENIED}}
|
||||
end;
|
||||
handle_info({auth_reply, {error, Reason}}, State = #state{transport_pid = TransportPid, status = ?STATE_AUTH}) ->
|
||||
efka_logger:debug("[efka_agent] auth_request failed, error: ~p", [Reason]),
|
||||
lager:debug("[efka_agent] auth_request failed, error: ~p", [Reason]),
|
||||
efka_transport:stop(TransportPid),
|
||||
{noreply, State#state{transport_pid = undefined, status = ?STATE_DENIED}};
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user