From ff2022d9a04a99dbb7337e3c3f7d27b9d0931e9d Mon Sep 17 00:00:00 2001 From: JianBo He Date: Fri, 1 Apr 2022 14:08:30 +0800 Subject: [PATCH] fix(exproto): keep conn_mod attribute in ConnInfo --- apps/emqx_gateway/src/emqx_gateway_api_clients.erl | 6 +++++- apps/emqx_gateway/src/emqx_gateway_cm.erl | 8 ++++---- apps/emqx_gateway/src/exproto/emqx_exproto_channel.erl | 1 - 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/apps/emqx_gateway/src/emqx_gateway_api_clients.erl b/apps/emqx_gateway/src/emqx_gateway_api_clients.erl index 29953cc38..dfeceb24e 100644 --- a/apps/emqx_gateway/src/emqx_gateway_api_clients.erl +++ b/apps/emqx_gateway/src/emqx_gateway_api_clients.erl @@ -177,6 +177,8 @@ subscriptions(get, #{ ClientId = emqx_mgmt_util:urldecode(ClientId0), with_gateway(Name0, fun(GwName, _) -> case emqx_gateway_http:list_client_subscriptions(GwName, ClientId) of + {error, not_found} -> + return_http_error(404, "client process not found"); {error, Reason} -> return_http_error(500, Reason); {ok, Subs} -> @@ -202,8 +204,10 @@ subscriptions(post, #{ GwName, ClientId, Topic, SubOpts ) of + {error, not_found} -> + return_http_error(404, "client process not found"); {error, Reason} -> - return_http_error(404, Reason); + return_http_error(500, Reason); {ok, {NTopic, NSubOpts}} -> {201, maps:merge(NSubOpts, #{topic => NTopic})} end diff --git a/apps/emqx_gateway/src/emqx_gateway_cm.erl b/apps/emqx_gateway/src/emqx_gateway_cm.erl index 5a7c0468d..25665c762 100644 --- a/apps/emqx_gateway/src/emqx_gateway_cm.erl +++ b/apps/emqx_gateway/src/emqx_gateway_cm.erl @@ -694,17 +694,17 @@ call(GwName, ClientId, Req, Timeout) -> do_call(GwName, ClientId, ChanPid, Req) -> case do_get_chann_conn_mod(GwName, ClientId, ChanPid) of - undefined -> throw(noproc); + undefined -> undefined; ConnMod -> ConnMod:call(ChanPid, Req) end. do_call(GwName, ClientId, ChanPid, Req, Timeout) -> case do_get_chann_conn_mod(GwName, ClientId, ChanPid) of - undefined -> throw(noproc); + undefined -> undefined; ConnMod -> ConnMod:call(ChanPid, Req, Timeout) end. --spec cast(gateway_name(), emqx_types:clientid(), term()) -> ok. +-spec cast(gateway_name(), emqx_types:clientid(), term()) -> undefined | ok. cast(GwName, ClientId, Req) -> with_channel( GwName, @@ -719,7 +719,7 @@ cast(GwName, ClientId, Req) -> do_cast(GwName, ClientId, ChanPid, Req) -> case do_get_chann_conn_mod(GwName, ClientId, ChanPid) of - undefined -> throw(noproc); + undefined -> undefined; ConnMod -> ConnMod:cast(ChanPid, Req) end. diff --git a/apps/emqx_gateway/src/exproto/emqx_exproto_channel.erl b/apps/emqx_gateway/src/exproto/emqx_exproto_channel.erl index 121439498..c0cce4456 100644 --- a/apps/emqx_gateway/src/exproto/emqx_exproto_channel.erl +++ b/apps/emqx_gateway/src/exproto/emqx_exproto_channel.erl @@ -722,7 +722,6 @@ default_conninfo(ConnInfo) -> clean_start => true, clientid => undefined, username => undefined, - conn_mod => undefined, conn_props => #{}, connected => true, proto_name => <<"exproto">>,