diff --git a/apps/emqx_gateway_exproto/src/emqx_exproto_channel.erl b/apps/emqx_gateway_exproto/src/emqx_exproto_channel.erl index 0caf4d7b2..2e5306f6b 100644 --- a/apps/emqx_gateway_exproto/src/emqx_exproto_channel.erl +++ b/apps/emqx_gateway_exproto/src/emqx_exproto_channel.erl @@ -297,7 +297,7 @@ handle_timeout( NChannel = remove_timer_ref(alive_timer, Channel), %% close connection if keepalive timeout Replies = [{event, disconnected}, {close, keepalive_timeout}], - NChannel1 = dispatch(on_timer_timeout, Req, NChannel), + NChannel1 = dispatch(on_timer_timeout, Req, NChannel#channel{closed_reason = keepalive_timeout}), {ok, Replies, NChannel1} end; handle_timeout(_TRef, force_close, Channel = #channel{closed_reason = Reason}) -> @@ -497,7 +497,7 @@ handle_cast(Req, Channel) -> | {shutdown, Reason :: term(), channel()}. handle_info( {sock_closed, Reason}, - Channel = #channel{gcli = GClient} + Channel = #channel{gcli = GClient, closed_reason = ClosedReason} ) -> case emqx_exproto_gcli:is_empty(GClient) of true -> @@ -505,7 +505,12 @@ handle_info( {shutdown, Reason, Channel1}; _ -> %% delayed close process for flushing all callback funcs to gRPC server - Channel1 = Channel#channel{closed_reason = Reason}, + Channel1 = case ClosedReason of + undefined -> + Channel#channel{closed_reason = Reason}; + _ -> + Channel + end, Channel2 = ensure_timer(force_timer, Channel1), {ok, ensure_disconnected(Reason, Channel2)} end; diff --git a/rel/i18n/emqx_exproto_schema.hocon b/rel/i18n/emqx_exproto_schema.hocon index 92e2d5eb2..db9dd2480 100644 --- a/rel/i18n/emqx_exproto_schema.hocon +++ b/rel/i18n/emqx_exproto_schema.hocon @@ -13,8 +13,7 @@ of requests in `ConnectionHandler`. But unfortunately, events between different streams are out of order. It causes the `OnSocketCreated` event to may arrive later than `OnReceivedBytes`. So we added the `ConnectionUnaryHandler` service since v5.0.25 and forced -the use of Unary in it to avoid ordering problems. -""" +the use of Unary in it to avoid ordering problems.""" exproto_grpc_handler_ssl.desc: """SSL configuration for the gRPC client."""