diff --git a/apps/emqx_gateway/src/emqx_gateway_api_clients.erl b/apps/emqx_gateway/src/emqx_gateway_api_clients.erl index aedb4b0fa..121cb4064 100644 --- a/apps/emqx_gateway/src/emqx_gateway_api_clients.erl +++ b/apps/emqx_gateway/src/emqx_gateway_api_clients.erl @@ -197,6 +197,10 @@ subscriptions(get, #{ case emqx_gateway_http:list_client_subscriptions(GwName, ClientId) of {error, not_found} -> return_http_error(404, "client process not found"); + {error, ignored} -> + return_http_error( + 400, "get subscriptions failed: unsupported" + ); {error, Reason} -> return_http_error(400, Reason); {ok, Subs} -> @@ -222,7 +226,13 @@ subscriptions(post, #{ ) of {error, not_found} -> - return_http_error(404, "client process not found"); + return_http_error( + 404, "client process not found" + ); + {error, ignored} -> + return_http_error( + 400, "subscribe failed: unsupported" + ); {error, Reason} -> return_http_error(400, Reason); {ok, {NTopic, NSubOpts}} -> @@ -241,8 +251,14 @@ subscriptions(delete, #{ with_gateway(Name0, fun(GwName, _) -> case lookup_topic(GwName, ClientId, Topic) of {ok, _} -> - _ = emqx_gateway_http:client_unsubscribe(GwName, ClientId, Topic), - {204}; + case emqx_gateway_http:client_unsubscribe(GwName, ClientId, Topic) of + {error, ignored} -> + return_http_error( + 400, "unsubscribe failed: unsupported" + ); + _ -> + {204} + end; {error, not_found} -> return_http_error(404, "Resource not found") end diff --git a/apps/emqx_gateway/src/emqx_gateway_http.erl b/apps/emqx_gateway/src/emqx_gateway_http.erl index 677176acc..802bbb689 100644 --- a/apps/emqx_gateway/src/emqx_gateway_http.erl +++ b/apps/emqx_gateway/src/emqx_gateway_http.erl @@ -378,6 +378,8 @@ client_call(GwName, ClientId, Req) -> of undefined -> {error, not_found}; + ignored -> + {error, ignored}; Res -> Res catch