Environment:
-
在我的环境中,Kibana 4.5.2在"reverse proxy servlet"后面运行,它是通过扩展Jetty的"ProxyServlet"类创建的 .
-
这样做是为了可以使用URL https://Jetty_Server_IP:8443/visual-analytics/proxy/访问Kibana Web界面...此URL的请求被Jetty服务器中运行的反向代理拦截并重定向到https://localhost:5601/ ...即,到Kibana Server是与Jetty Server在同一台机器上运行 .
-
然后,Kibana Server处理Jetty服务器转发的请求,并将响应返回给Web浏览器 .
-
NOTE: Jetty在我的应用程序中的"embedded mode"中运行 .
Issue:
“反向代理servlet”映射到URL“/ visual-analytics / proxy / *” .
还有另一个“过滤器”映射到URL“/visual-analytics/proxy/elasticsearch/.kibana/search/*”,其中正在使用“ContinuationListener”,如下面的代码片段所示:
ContinuationSupport.getContinuation(myRequestWrapper).addContinuationListener(new ContinuationListener() {
@Override
public void onTimeout(Continuation continuation) {
logger.log(Level.WARNING, "Request timeout...");
}
@Override
public void onComplete(Continuation continuation) {
HttpServletResponse httpResponse = (HttpServletResponse)continuation.getServletResponse();
if (httpResponse.getStatus() == HttpServletResponse.SC_OK || httpResponse.getStatus() == HttpServletResponse.SC_CREATED ) {
//some business logic
}
}
});
chain.doFilter(myRequestWrapper, response);
上面的ContinuationListener与 Jetty version 8.1.15.v20140411 正常工作,并且正在调用侦听器的onComplete()方法 . 但是在将Jetty版本升级到 9.3.14.v20161028 之后,ContinuationListener不再工作,即,不会调用侦听器的onComplete()方法和onTimeout()方法 .
任何可能出错的指针或如何进一步调试此问题将不胜感激 . 期待任何回应......
1 回答
仅供参考我修正了这个问题如下:
取代了之前使用Jetty 's 360270 with Servlet 3.0' s "AsyncListener"的方法,因为Jetty的"ContinuationListener"在升级到 Jetty 9.3.14.v20161028 后似乎不起作用 . 这可能是一个Jetty错误 .
与侦听器相关的代码段位于过滤器的“chain.doFilter()”调用之前 . 我将此代码段移动到过滤器的"chain.doFilter()"调用之后的位置,以便我可以在Jetty ProxyServlet的service()方法中检索"already created"的AsyncContext . 然后,我可以向检索到的AsyncContext添加AsyncListener .
我没有在我的过滤器中使用“request.startAsync()”调用,而是使用“request.getAsyncContext()”,这样我就不会启动一个新的AsyncContext导致IllegalStateException,而只是检索AsyncContext . 已经在Jetty的ProxyServlet中创建 .
所以更新的代码段看起来像这样: