Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tomcat 8.x + Jersey ( 1.18.1 ) + atmosphere-runtime 2.2.x cannot correctly route WebSocket requests due to an incorrect requestURI implementation in org.atmosphere.container.JSR356Endpoint.onOpen #1839

Closed
lone-cloud opened this issue Jan 20, 2015 · 7 comments
Labels

Comments

@lone-cloud
Copy link

Hi,

I've had atmosphere running well under Tomcat 7.0.55; however, after an upgrade to Tomcat 8.15 ( and now 8.0.17 ) it all fell apart. I've been debugging the stack trace and the problem seems to originate due to an incompatibility between
the requestURI value created within atmosphere-runtime-2.2.4.jar:JSR356Endpoint.onOpen() and the requestURI expected by jersey-server-1.18.1.jar:ServletContainer.service(). In my case, atmosphere creates the requestURI like "http://localhost:8080/com.absolute.am.webapi/api/push" where as jersey expects it to be like "/com.absolute.am.webapi/api/push".

Maven:

    <dependency>
        <groupId>org.atmosphere</groupId>
        <artifactId>atmosphere-jersey</artifactId>
        <version>2.2.4</version>
    </dependency>

web.xml:

<servlet>
    <servlet-name>APIServlet</servlet-name>
    <servlet-class>org.atmosphere.cpr.AtmosphereServlet</servlet-class>
    ...
    <async-supported>true</async-supported>
</servlet>

<servlet-mapping>
    <servlet-name>APIServlet</servlet-name>
    <url-pattern>/api/*</url-pattern>
</servlet-mapping>

The HTTP request:

request

Generated using atmosphere.js ( version 2.2.4 ):

var socket;
var transport = 'websocket';
var request = {
url: 'http://localhost:8080/com.absolute.am.webapi/api/push',
contentType: 'application/json',
transport: transport,
reconnectOnServerError: false,
maxReconnectOnClose: 0,
fallbackTransport: 'none'
};
...
socket = atmosphere.subscribe(request);

Stack trace:

ERROR c.a.am.webapi.JAXRSExceptionMapper - JAXRSExceptionMapper unhandled exception={}
com.sun.jersey.api.NotFoundException: null for uri: http://localhost:8080/http://localhost:8080/com.absolute.am.webapi/api/push
at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1543) [jersey-server-1.18.1.jar:1.18.1]
at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1473) [jersey-server-1.18.1.jar:1.18.1]
at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1419) [jersey-server-1.18.1.jar:1.18.1]
at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1409) [jersey-server-1.18.1.jar:1.18.1]
at com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:409) [jersey-servlet-1.18.1.jar:1.18.1]
at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:540) [jersey-servlet-1.18.1.jar:1.18.1]
at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:715) [jersey-servlet-1.18.1.jar:1.18.1]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:725) [servlet-api.jar:na]
at org.atmosphere.util.AtmosphereFilterChain.doFilter(AtmosphereFilterChain.java:135) [atmosphere-runtime-2.2.4.jar:2.2.4]
at org.atmosphere.util.AtmosphereFilterChain.invokeFilterChain(AtmosphereFilterChain.java:96) [atmosphere-runtime-2.2.4.jar:2.2.4]
at org.atmosphere.handler.ReflectorServletProcessor$FilterChainServletWrapper.service(ReflectorServletProcessor.java:317) [atmosphere-runtime-2.2.4.jar:2.2.4]
at org.atmosphere.handler.ReflectorServletProcessor.onRequest(ReflectorServletProcessor.java:160) [atmosphere-runtime-2.2.4.jar:2.2.4]
at org.atmosphere.cpr.AsynchronousProcessor.action(AsynchronousProcessor.java:205) [atmosphere-runtime-2.2.4.jar:2.2.4]
at org.atmosphere.cpr.AsynchronousProcessor.suspended(AsynchronousProcessor.java:104) [atmosphere-runtime-2.2.4.jar:2.2.4]
at org.atmosphere.container.Servlet30CometSupport.service(Servlet30CometSupport.java:66) [atmosphere-runtime-2.2.4.jar:2.2.4]
at org.atmosphere.cpr.AtmosphereFramework.doCometSupport(AtmosphereFramework.java:2079) [atmosphere-runtime-2.2.4.jar:2.2.4]
at org.atmosphere.websocket.DefaultWebSocketProcessor.dispatch(DefaultWebSocketProcessor.java:570) [atmosphere-runtime-2.2.4.jar:2.2.4]
at org.atmosphere.websocket.DefaultWebSocketProcessor.open(DefaultWebSocketProcessor.java:215) [atmosphere-runtime-2.2.4.jar:2.2.4]
at org.atmosphere.container.JSR356Endpoint.onOpen(JSR356Endpoint.java:198) [atmosphere-runtime-2.2.4.jar:2.2.4]
at org.apache.tomcat.websocket.server.WsHttpUpgradeHandler.init(WsHttpUpgradeHandler.java:138) [tomcat-websocket.jar:8.0.17]
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:687) [tomcat-coyote.jar:8.0.17]
at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:285) [tomcat-coyote.jar:8.0.17]
at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.doRun(AprEndpoint.java:2431) [tomcat-coyote.jar:8.0.17]
at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:2420) [tomcat-coyote.jar:8.0.17]
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) [na:1.7.0_67]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [na:1.7.0_67]
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) [tomcat-util.jar:8.0.17]
at java.lang.Thread.run(Unknown Source) [na:1.7.0_67]

Key points:

JSR356Endpoint:

ServletContainer

@jfarcand
Copy link
Member

Already fixed in 2.3,0-SNAPSHOT. Can you try it?

https://github.com/Atmosphere/atmosphere/wiki/Downloading-Atmosphere's-SNAPSHOT

Thanks.

@jfarcand
Copy link
Member

I will port the fix to 2.2.5 once you confirm. Thanks

@jfarcand
Copy link
Member

#1838

@lone-cloud
Copy link
Author

It's working as expected again with the 2.3.0-SNAPSHOT. I don't recall seeing a bunch of 'X's being sent back though the WebSocket before. Is this something you've committed before for debugging?

request

@jfarcand
Copy link
Member

@hoboman313 This is the new heartbeat char. I wll backport the fix to 2.2.5-SNAPSHOT. Thanks for the help!

@jfarcand
Copy link
Member

@hoboman313 Backported to 2.2.5. I'm not planning a 2.2.x release as I want to focus on 2.3, then I can cut another 2.2.x somewhere in March.

@lone-cloud
Copy link
Author

I should be able to live with the 2.2.5-SNAPSHOT until then. Thanks for the quick turnaround.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants