SocketIo.use(function(socket, next)) - Where goes next, how to catch or receive it?
It goes to the client.
https://socket.io/docs/server-api/#socket-use-fn
Errors passed to middleware callbacks are sent as special
error
packets to clients.io.on('connection', (socket) => { socket.use((packet, next) => { if (packet.doge === true) return next(); next(new Error('Not a doge error')); }); });
Note that any middlewares following it aren't invoked.
On the client-side you can handle then like so:
socket.on('error', function(err){
// do something with err
});