jetty 在请求URI里传入非法字符,jetty会断开连接,导致nginx认为该节点不健康
為什么80%的碼農(nóng)都做不了架構(gòu)師?>>> ??
jetty 在請求URI里傳入非法字符(如直接一個16進(jìn)制字節(jié)A1,非%A1,用抓包TCP工具發(fā)送),jetty拋出如下錯誤
8.1.0.RC1、
8.1.18.v20150929、
9.3好的
如果前面代理用nginx的proxy_next_upstream,會認(rèn)為該節(jié)點(diǎn)失效,如果請求刷的厲害,有可能所有節(jié)點(diǎn)都被刷成不健康狀態(tài);導(dǎo)致nginx返回給用戶502;
org.eclipse.jetty.util.Utf8Appendable$NotUtf8Exception: Not valid UTF8! byte Fd in state 0at 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轉(zhuǎn)碼失敗會使用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,代碼里調(diào)用 Request.getRequestURI,用utf-8轉(zhuǎn)碼,引起異常,導(dǎo)致直接關(guān)閉連接;
初步解決思路:
1.升9版本,但是jetty9.3默認(rèn)是編譯jdk8,jdk還在6跑著,風(fēng)險(xiǎn)不小
2.nginx改nginx_upstream_check_module
http://nolinux.blog.51cto.com/4824967/1594029
3.改下8.1.18的代碼(手生哎),初步想法
response.sendError()--->request.getRequestURI()-->HttpURI.getPathAndParam發(fā)生NotUtf8Exception換用8599-1獲取
public String getPathAndParamISO8859(){if (_path==_query)return null;return StringUtil.toString(_raw,_path,_param-_path,StringUtil.__ISO_8859_1);}
4.proxy_next_upstream 最后加個max_fails=0的節(jié)點(diǎn),反正前面都錯了,這個節(jié)點(diǎn)撐著(沒人故意刷你死不了);
?
jetty,nginx都不算熟悉,有大牛請指導(dǎo)、自己記錄,誤人勿怪!!!!
轉(zhuǎn)載于:https://my.oschina.net/greki/blog/530951
總結(jié)
以上是生活随笔為你收集整理的jetty 在请求URI里传入非法字符,jetty会断开连接,导致nginx认为该节点不健康的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Sqlite使用技巧集锦
- 下一篇: Objective-c(1)