@NonNull
        @Override
        public Mono<Void> handle(@NonNull final WebSocketSession session) {
            // pass headers along so custom headers can be sent through
            return client.execute(url, this.headers, new WebSocketHandler() {

                @NonNull
                @Override
                public Mono<Void> handle(@NonNull final WebSocketSession proxySocketSession) {
                    Mono<Void> serverClose = proxySocketSession.closeStatus().filter(it -> session.isOpen())
                        .map(WebSocketPlugin::adaptCloseStatus).flatMap(session::close);
                    Mono<Void> proxyClose = session.closeStatus().filter(it -> proxySocketSession.isOpen())
                        .map(WebSocketPlugin::adaptCloseStatus).flatMap(proxySocketSession::close);
                    // Use retain() for Reactor Netty
                    Mono<Void> proxySessionSend = proxySocketSession
                        .send(session.receive().doOnNext(WebSocketMessage::retain));
                    Mono<Void> serverSessionSend = session.send(
                        proxySocketSession.receive().doOnNext(WebSocketMessage::retain));
                    // Ensure closeStatus from one propagates to the other
                    Mono.when(serverClose, proxyClose).subscribe();
                    return Mono.zip(proxySessionSend, serverSessionSend).then();
                }

                @NonNull
                @Override
                public List<String> getSubProtocols() {
                    return ShenyuWebSocketHandler.this.subProtocols;
                }
            });
        }
Instantiates a new shenyu web socket handler.

@param url       the url
@param client    the client
@param headers   the headers
@param protocols the protocols
shenyu-plugin/shenyu-plugin-proxy/shenyu-plugin-websocket/src/main/java/org/apache/shenyu/plugin/websocket/WebSocketPlugin.java