private static Connection attachChannel(final Channel channel, final List<ConnectionClosedEventListener> listeners) {
        if (channel == null) {
            return null;
        }

        final Attribute<NettyConnection> attr = channel.attr(NETTY_CONN_KEY);
        NettyConnection conn = attr.get();
        if (conn == null) {
            final NettyConnection newConn = new NettyConnection(channel);
            conn = attr.setIfAbsent(newConn);
            if (conn == null) {
                conn = newConn;
                for (final ConnectionClosedEventListener l : listeners) {
                    conn.addClosedEventListener(l);
                }
            }
        }

        return conn;
    }
Get netty channel.

@author jiachun.fjc
jraft-extension/rpc-grpc-impl/src/main/java/io/grpc/netty/shaded/io/grpc/netty/NettyConnectionHelper.java