engine.io-server-java icon indicating copy to clipboard operation
engine.io-server-java copied to clipboard

How to reject a client connection?

Open Ryniu3001 opened this issue 3 years ago • 1 comments

Hi, how to reject a client connection properly? I have something like this:

SocketIoNamespace ns = mSocketIoServer.namespace("/");
    ns.on("connection", args -> {
        SocketIoSocket socket = (SocketIoSocket) args[0];
        //verify JWT token
        if (isTokenInvalid()) {
            socket.disconnect(true);
        }
    })

socket.disconnect(true) doesn't interrupt the whole connection process, so I am not sure if it's correct solution (e.g. disconnect() method clears mSockets Map inside SocketIoClient, but right after that, method onConnect() put something to that map and the rest of the connection process takes place).

Thanks for answers.

Ryniu3001 avatar Jul 13 '22 08:07 Ryniu3001

Hi, I've updated the mechanism in the latest release to allow this use case. Please check it out.

trinopoty avatar Aug 02 '23 18:08 trinopoty