Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Biz Exceptions occured in EventMesh cause connection close of client #476

Closed
lrhkobe opened this issue Jul 29, 2021 · 0 comments
Closed
Labels
bug Something isn't working
Milestone

Comments

@lrhkobe
Copy link
Contributor

lrhkobe commented Jul 29, 2021

Bug Report

Describe the bug

When exception occured in the method of channelRead0, it will be thrown, and handled by the method 'exceptionCaught' in the class of EventMeshTcpExceptionHandler .

public class EventMeshTcpMessageDispatcher extends SimpleChannelInboundHandler<Package> {

    @Override
    protected void channelRead0(ChannelHandlerContext ctx, Package pkg) throws Exception { 
        try {
            ...

            dispatch(ctx, pkg, startTime, cmd);
        } catch (Exception e) {
            logger.error("exception occurred while pkg|cmd={}|pkg={}|errMsg={}", cmd, pkg, e);
            //throw new RuntimeException(e);
            throw e;
        }
    }
}

When EventMesh caught the exception, it will send goodbye instruction to the client, that means the biz exception caused the connection close of client. It seems unreasonable.

public class EventMeshTcpExceptionHandler extends ChannelDuplexHandler {

    @Override
    public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
        Session session = eventMeshTCPServer.getClientSessionGroupMapping().getSession(ctx);
        UserAgent client = session == null ? null : session.getClient();
        logger.error("exceptionCaught, push goodbye to client|user={},errMsg={}", client, cause.fillInStackTrace());
        String errMsg;
        if (cause.toString().contains("value not one of declared Enum instance names")) {
            errMsg = "Unknown Command type";
        } else {
            errMsg = cause.toString();
        }

        if (session != null) {
            EventMeshTcp2Client.goodBye2Client(eventMeshTCPServer, session, errMsg, OPStatus.FAIL.getCode(), eventMeshTCPServer.getClientSessionGroupMapping());
        } else {
            EventMeshTcp2Client.goodBye2Client(ctx, errMsg, eventMeshTCPServer.getClientSessionGroupMapping(), eventMeshTCPServer.getEventMeshTcpMonitor());
        }
    }
}
@lrhkobe lrhkobe added the bug Something isn't working label Jul 29, 2021
@xwm1992 xwm1992 closed this as completed in 05e3421 Aug 2, 2021
@xwm1992 xwm1992 added this to the 1.3.0 milestone Dec 16, 2021
@xwm1992 xwm1992 changed the title Biz Exceptions occured in EventMesh cause connection close of client [Bug] Biz Exceptions occured in EventMesh cause connection close of client Dec 16, 2021
xwm1992 pushed a commit to xwm1992/EventMesh that referenced this issue Dec 27, 2021
…on close of client (apache#477)

* modify:optimize flow control in downstreaming msg

* modify:optimize stategy of selecting session in downstream msg

* modify:optimize msg downstream,msg store in session

* modify:fix bug:not a @sharable handler

* modify:downstream broadcast msg asynchronously

* modify:remove unneccessary interface in eventmesh-connector-api

* modify:fix conflict

* modify:add license in EventMeshAction

* modify:fix ack problem

* modify:fix exception handle when exception occured in EventMeshTcpMessageDispatcher

* modify:fix log print

close apache#476
xwm1992 pushed a commit that referenced this issue Aug 4, 2022
…se of client (#477)

* modify:optimize flow control in downstreaming msg

* modify:optimize stategy of selecting session in downstream msg

* modify:optimize msg downstream,msg store in session

* modify:fix bug:not a @sharable handler

* modify:downstream broadcast msg asynchronously

* modify:remove unneccessary interface in eventmesh-connector-api

* modify:fix conflict

* modify:add license in EventMeshAction

* modify:fix ack problem

* modify:fix exception handle when exception occured in EventMeshTcpMessageDispatcher

* modify:fix log print

close #476
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants