我運行一個使用Atmosphere作爲websocket支持框架的聊天服務器。大氣使用澤西島,因爲我使用的氣氛澤西maven依賴。氛圍+ Tomcat 8和非Atmosphere客戶端的澤西錯誤
聊天服務器在Tomcat 7中運行,我們正在升級到Tomcat 8
我們的一個客戶用泰魯斯 - 作爲他們的Java API的WebSocket。
當我們的聊天服務器部署在Tomcat 7上(Java 6,7或8)時,沒有任何問題。
通過Tomcat 8(Java 8)上的聊天服務器,我們使用Atmosphere的測試客戶端運行正常,但使用Tyrus的客戶端卻沒有。我們所看到的錯誤是:
2017-01-17 02:36:51,114 ERROR() [http-nio-8443-exec-11] ReflectorServletProcessor (?) - onRequest()
java.lang.IllegalArgumentException: Schema specific part is opaque
at com.sun.jersey.api.uri.UriBuilderImpl.checkSsp(UriBuilderImpl.java:529)
at com.sun.jersey.api.uri.UriBuilderImpl.replacePath(UriBuilderImpl.java:256)
at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:703)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
at org.atmosphere.util.AtmosphereFilterChain.doFilter(AtmosphereFilterChain.java:135)
at org.atmosphere.util.AtmosphereFilterChain.invokeFilterChain(AtmosphereFilterChain.java:96)
at org.atmosphere.handler.ReflectorServletProcessor$FilterChainServletWrapper.service(ReflectorServletProcessor.java:317)
at org.atmosphere.handler.ReflectorServletProcessor.onRequest(ReflectorServletProcessor.java:160)
at org.atmosphere.cpr.AsynchronousProcessor.action(AsynchronousProcessor.java:199)
at org.atmosphere.cpr.AsynchronousProcessor.suspended(AsynchronousProcessor.java:107)
at org.atmosphere.container.Servlet30CometSupport.service(Servlet30CometSupport.java:66)
at org.atmosphere.cpr.AtmosphereFramework.doCometSupport(AtmosphereFramework.java:2078)
at org.atmosphere.websocket.DefaultWebSocketProcessor.dispatch(DefaultWebSocketProcessor.java:571)
at org.atmosphere.websocket.DefaultWebSocketProcessor$3.run(DefaultWebSocketProcessor.java:333)
at org.atmosphere.util.VoidExecutorService.execute(VoidExecutorService.java:101)
at org.atmosphere.websocket.DefaultWebSocketProcessor.dispatch(DefaultWebSocketProcessor.java:328)
at org.atmosphere.websocket.DefaultWebSocketProcessor.invokeWebSocketProtocol(DefaultWebSocketProcessor.java:525)
at org.atmosphere.websocket.DefaultWebSocketProcessor.invokeWebSocketProtocol(DefaultWebSocketProcessor.java:428)
at org.atmosphere.container.JSR356Endpoint$1.onMessage(JSR356Endpoint.java:213)
at org.atmosphere.container.JSR356Endpoint$1.onMessage(JSR356Endpoint.java:210)
at org.apache.tomcat.websocket.WsFrameBase.sendMessageText(WsFrameBase.java:393)
at org.apache.tomcat.websocket.WsFrameBase.processDataText(WsFrameBase.java:494)
at org.apache.tomcat.websocket.WsFrameBase.processData(WsFrameBase.java:289)
at org.apache.tomcat.websocket.WsFrameBase.processInputBuffer(WsFrameBase.java:130)
at org.apache.tomcat.websocket.server.WsFrameServer.onDataAvailable(WsFrameServer.java:60)
at org.apache.tomcat.websocket.server.WsHttpUpgradeHandler$WsReadListener.onDataAvailable(WsHttpUpgradeHandler.java:183)
at org.apache.coyote.http11.upgrade.AbstractServletInputStream.onDataAvailable(AbstractServletInputStream.java:198)
at org.apache.coyote.http11.upgrade.AbstractProcessor.upgradeDispatch(AbstractProcessor.java:96)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:669)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1500)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1456)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:745)
這是因爲在Tomcat 7,從WebSocket的請求的請求的URL被視爲類似的「http://本地主機:8080 /聊天/」(請求是由到ws:// localhost:8080/chat /,但它已更改爲http:// somewhere)。但是對於Tomcat 8,來自websocket請求的請求URL與「/ chat /」類似,並且模式不存在,Jersey會引發錯誤。
爲了解決這個問題,Atmosphere會在Atmosphere客戶端發出請求時查找包含模式的標題「origin」。但是,當一個Tyrus客戶端發出請求時,這個「origin」頭文件不包含導致上面顯示的錯誤的http模式。
我想知道是否有人有任何想法爲此簡單的解決方案或碰到類似的問題。我做了很多搜索簡單的解決方案,但還沒有找到。沒有人,我們正在考慮不得不停止使用Atmosphere並使用其他代碼重構的其他內容。
這些是關於這個問題的票據/錯誤的一些鏈接,似乎已經解決了這個問題,但我有正確的版本,仍然有問題。
https://bz.apache.org/bugzilla/show_bug.cgi?id=56573 https://github.com/Atmosphere/atmosphere/issues/1839
氣氛版本:2.4.8
澤西版本(經由氣氛):1.19
泰魯斯版本:1.13