if (url.getQuery() != null && url.getQuery().length() > 0) {
path = url.getPath() + "?" + url.getQuery();
}
HttpRequest request = new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, path);
request.addHeader(Names.UPGRADE, Values.WEBSOCKET);
request.addHeader(Names.CONNECTION, Values.UPGRADE);
request.addHeader(Names.HOST, url.getHost());
request.addHeader(Names.ORIGIN, "http://" + url.getHost());
e.getChannel().write(request);
ctx.getPipeline().replace("encoder", "ws-encoder", new WebSocketFrameEncoder());