Преглед изворни кода

Merge pull request #7931 from HJianBo/gw-fixes

Increase the wait time to get the error of creating authn
JianBo He пре 3 година
родитељ
комит
bcac65310b

+ 3 - 1
apps/emqx_gateway/src/emqx_gateway_insta_sup.erl

@@ -87,7 +87,9 @@ update(Pid, Config) ->
     call(Pid, {update, Config}).
 
 call(Pid, Req) ->
-    gen_server:call(Pid, Req, 5000).
+    %% The large timeout aim to get the modified results of the dependent
+    %% resources
+    gen_server:call(Pid, Req, 15000).
 
 %%--------------------------------------------------------------------
 %% gen_server callbacks

+ 5 - 4
apps/emqx_gateway/src/exproto/emqx_exproto_impl.erl

@@ -167,16 +167,17 @@ start_grpc_server(GwName, Options = #{bind := ListenOn}) ->
                         )}
                 ]
         end,
+    ListenOnStr = emqx_listeners:format_addr(ListenOn),
     case grpc:start_server(GwName, ListenOn, Services, SvrOptions) of
         {ok, _SvrPid} ->
             console_print(
-                "Start ~ts gRPC server on ~p successfully.~n",
-                [GwName, ListenOn]
+                "Start ~ts gRPC server on ~s successfully.~n",
+                [GwName, ListenOnStr]
             );
         {error, Reason} ->
             ?ELOG(
-                "Failed to start ~ts gRPC server on ~p, reason: ~0p",
-                [GwName, ListenOn, Reason]
+                "Failed to start ~ts gRPC server on ~s, reason: ~0p",
+                [GwName, ListenOnStr, Reason]
             ),
             throw(
                 {badconf, #{

+ 2 - 4
apps/emqx_gateway/test/emqx_gateway_api_SUITE.erl

@@ -211,9 +211,7 @@ t_gateway_exproto_with_ssl(_) ->
         name => <<"exproto">>,
         server => #{
             bind => <<"9100">>,
-            ssl => SslSvrOpts#{
-                enable => true
-            }
+            ssl => SslSvrOpts
         },
         handler => #{
             address => <<"http://127.0.0.1:9001">>,
@@ -230,7 +228,7 @@ t_gateway_exproto_with_ssl(_) ->
     GwConf2 = emqx_map_lib:deep_merge(GwConf, #{
         server => #{
             bind => <<"9200">>,
-            ssl => SslCliOpts#{enable => true}
+            ssl => SslCliOpts
         }
     }),
     {200, _} = request(put, "/gateway/exproto", maps:without([name, listeners], GwConf2)),

+ 15 - 4
apps/emqx_management/src/emqx_mgmt_api_clients.erl

@@ -862,10 +862,12 @@ format_channel_info({_, ClientInfo0, ClientStats}) ->
         ],
     TimesKeys = [created_at, connected_at, disconnected_at],
     %% format timestamp to rfc3339
-    lists:foldl(
-        fun result_format_time_fun/2,
-        maps:without(RemoveList, ClientInfoMap),
-        TimesKeys
+    result_format_undefined_to_null(
+        lists:foldl(
+            fun result_format_time_fun/2,
+            maps:without(RemoveList, ClientInfoMap),
+            TimesKeys
+        )
     ).
 
 %% format func helpers
@@ -884,6 +886,15 @@ result_format_time_fun(Key, NClientInfoMap) ->
             NClientInfoMap
     end.
 
+result_format_undefined_to_null(Map) ->
+    maps:map(
+        fun
+            (_, undefined) -> null;
+            (_, V) -> V
+        end,
+        Map
+    ).
+
 -spec peername_dispart(emqx_types:peername()) -> {binary(), inet:port_number()}.
 peername_dispart({Addr, Port}) ->
     AddrBinary = list_to_binary(inet:ntoa(Addr)),