jetty 在请求URI里传入非法字符(如直接一个16进制字节A1,非%A1,用抓包TCP工具发送),jetty抛出如下错误
8.1.0.RC1、
8.1.18.v20150929、
9.3好的
如果前面代理用nginx的proxy_next_upstream,会认为该节点失效,如果请求刷的厉害,有可能所有节点都被刷成不健康状态;导致nginx返回给用户502;
org.eclipse.jetty.util.Utf8Appendable$NotUtf8Exception: Not valid UTF8! byte Fd in state 0 at org.eclipse.jetty.util.Utf8Appendable.appendByte(Utf8Appendable.java:178) at org.eclipse.jetty.util.Utf8Appendable.append(Utf8Appendable.java:117) at org.eclipse.jetty.http.HttpURI.toUtf8String(HttpURI.java:503) at org.eclipse.jetty.http.HttpURI.getPathAndParam(HttpURI.java:687) at org.eclipse.jetty.server.Request.getRequestURI(Request.java:1024) at org.eclipse.jetty.server.Response.sendError(Response.java:364) at org.eclipse.jetty.server.Response.sendError(Response.java:419) at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:603) at org.eclipse.jetty.server.AbstractHttpConnection.headerComplete(AbstractHttpConnection.java:971) at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.headerComplete(AbstractHttpConnection.java:1033) at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:640) at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:231) at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:82) at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:696) at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:53) at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608) at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:543) at java.lang.Thread.run(Thread.java:695)
8.1.18在处理请求的时候,utf-8转码失败会使用ios-8859-1,找不到返回404
2015-11-16 15:37:43.763:WARN:oejs.AbstractHttpConnection:Failed UTF-8 decode for request path, trying ISO-8859-1
但是奇怪的是,在处理返回
Response.sendError,代码里调用
Request.getRequestURI,用utf-8转码,引起异常,导致直接关闭连接;
初步解决思路:
1.升9版本,但是jetty9.3默认是编译jdk8,jdk还在6跑着,风险不小
2.nginx改nginx_upstream_check_module
http://nolinux.blog.51cto.com/4824967/1594029
3.改下8.1.18的代码(手生哎)
4.proxy_next_upstream 最后加个max_fails=0的节点,反正前面都错了,这个节点撑着(没人故意刷你死不了);
jetty,nginx都不算熟悉,有大牛请指导、自己记录,误人勿怪!!!!
时间: 2024-10-22 23:07:01