Reputation: 197
I want to implement a simple push mechanism in my application. I am using TomEE 1.7 server which uses Tomcat along with bunch of other packages.
For Atmosphere I am using atmosphere-runtime 2.4.3 and on the client I am using 2.3.1 version.
Now when I try pushing using websockets then things works fine for me but when I try to use long-polling as the transport then I get the following error on server :
WARNING: Duplicate resource be43d07f-cbb4-412e-9d50-2d047a2e0223. Could be caused by a dead connection not detected by your server. Replacing the old one with the fresh one
browser connected be43d07f-cbb4-412e-9d50-2d047a2e0223
Mar 10, 2016 11:56:36 AM org.atmosphere.cpr.AtmosphereFramework doCometSupport
SEVERE: AtmosphereFramework exception
java.lang.IllegalStateException: A filter or servlet of the current chain does not support asynchronous operations.
at org.apache.catalina.connector.Request.startAsync(Request.java:1658)
at org.apache.catalina.connector.RequestFacade.startAsync(RequestFacade.java:1029)
at org.atmosphere.cpr.AtmosphereRequestImpl.startAsync(AtmosphereRequestImpl.java:623)
at org.atmosphere.container.Servlet30CometSupport.suspend(Servlet30CometSupport.java:95)
at org.atmosphere.container.Servlet30CometSupport.service(Servlet30CometSupport.java:70)
at org.atmosphere.cpr.AtmosphereFramework.doCometSupport(AtmosphereFramework.java:2287)
at org.atmosphere.cpr.AtmosphereServlet.doPost(AtmosphereServlet.java:191)
at org.atmosphere.cpr.AtmosphereServlet.doGet(AtmosphereServlet.java:177)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:620)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.catalina.filters.CorsFilter.handleSimpleCORS(CorsFilter.java:302)
at org.apache.catalina.filters.CorsFilter.doFilter(CorsFilter.java:166)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
at org.apache.tomee.catalina.OpenEJBValve.invoke(OpenEJBValve.java:44)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:501)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
at com.tradeweb.server.tools.valve.RequestHeaderCopyValve.invoke(RequestHeaderCopyValve.java:41)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1070)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:611)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316)
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)
And on the client I see the following issue (in case of chrome) :
GET http://127.0.0.1:43859/report-integrator-war/notification?X-Atmosphere-trac…ype=text%2Fplain%3B%20charset%3Dutf-8&X-atmo-protocol=true&_=1457628996834 net::ERR_INCOMPLETE_CHUNKED_ENCODING
_executeRequest @ atmosphere.js:2123
_reconnect @ atmosphere.js:2232
ajaxRequest.onreadystatechange @ atmosphere.js:2106
atmosphere.js:3258 Thu Mar 10 2016 11:56:36 GMT-0500 (Eastern Standard Time) Atmosphere: ajaxRequest.onreadystatechange, new state: 4
atmosphere.js:3258 Thu Mar 10 2016 11:56:36 GMT-0500 (Eastern Standard Time) Atmosphere: Firing onError, reasonPhrase: maxReconnectOnClose reached
atmosphere.js:3258 Thu Mar 10 2016 11:56:36 GMT-0500 (Eastern Standard Time) Atmosphere: Firing onError, reasonPhrase: maxReconnectOnClose reached
atmosphere.js:3258 Thu Mar 10 2016 11:56:36 GMT-0500 (Eastern Standard Time) Atmosphere: ajaxrequest.onerror
Here is my web.xml :
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">
<display-name>Portfolio Analytics Integrator</display-name>
<servlet>
<servlet-name>AtmosphereServlet</servlet-name>
<servlet-class>org.atmosphere.cpr.AtmosphereServlet</servlet-class>
<load-on-startup>0</load-on-startup>
<async-supported>true</async-supported>
</servlet>
<servlet-mapping>
<servlet-name>AtmosphereServlet</servlet-name>
<url-pattern>/notification/*</url-pattern>
</servlet-mapping>
</web-app>
Here we can see that I am using = true still the server complains that servlet does not support async operations.
I am relatively new to Atmosphere so unable to get what is the problem here. Also when I run the code on my local at least I can communicate via websockets but when I deploy the code in servers atmosphere fails to connect using websockets also and falls back to long-polling producing the above error. Same happens on my local when I using charles proxy in middle.
Upvotes: 1
Views: 1703
Reputation: 197
I have figured out the issue and looks like it was a TomEE 1.7.0 Server bug. The TomEE server was using was runnning tomcat 7.0.55.0. Here is the output of version.sh from TomEE :
[web@DEVTWDLNX05 bin]$ ./version.sh
Using CATALINA_BASE: /home/web/servers/apache-tomee-plus
Using CATALINA_HOME: /home/web/servers/apache-tomee-plus
Using CATALINA_TMPDIR: /home/web/servers/apache-tomee-plus/temp
Using JRE_HOME: /usr
Using CLASSPATH: /home/web/servers/apache-tomee-plus/bin/bootstrap.jar:/home/web/servers/apache-tomee-plus/bin/tomcat-juli.jar
Server version: Apache Tomcat/7.0.55
Server built: Jul 18 2014 05:34:04
Server number: 7.0.55.0
OS Name: Linux
OS Version: 3.8.13-55.1.6.el7uek.x86_64
Architecture: amd64
JVM Version: 1.7.0_75-mockbuild_2015_01_20_15_59-b00
JVM Vendor: Oracle Corporation
When I ran the code on TomEE 1.7.4 which runs Tomcat 7.0.68 everything ran fine.
The puzzling point is that I also ran the same code on plain vanilla Tomcat 7.0.55.0 and there code was working perfectly fine but when the same tomcat is packaged with TomEE server we are getting the error.
Upvotes: 0