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] onTimeout() failed for listener of type [org.apache.catalina.core.AsyncListenerWrapper] java.lang.IllegalStateException: Calling [asyncComplete()] is not valid for a request with Async state [MUST_COMPLETE] #1765

Closed
sspotorno opened this issue Nov 12, 2014 · 0 comments

Comments

@sspotorno
Copy link

Hi,

I am using atmosphere-meteor with LONG_POLLING transport. Due to a limitation in our cloud we suspend the connection in 25 seconds because every call lasting more than 25 seconds is killed by nginx. So our only solution was to do this:

class AppMeteorServlet extends MeteorServlet {

    private static final log = LogFactory.getLog(this)

    @Override
    public void init(ServletConfig sc) throws ServletException {
        super.init(sc)

        def servletConfig = AtmosphereConfigurationHolder.atmosphereMeteorConfig.servlets.get(sc.servletName)
        def mapping = servletConfig.mapping
        def handler = servletConfig.handler.newInstance()
        def handlerClass = handler.class.getName()

        ReflectorServletProcessor rsp = new ReflectorServletProcessor()
        rsp.setServletClassName(handlerClass)
        framework.addAtmosphereHandler(mapping, rsp)
        log.debug "Added AtmosphereHandler: $handlerClass mapped to $mapping"
    }
}

Handler:

class AppMeteorHandler extends HttpServlet {

    private static final log = LogFactory.getLog(this)

    @Override
    public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
        String path = request.getPathInfo()
        String mapping = '/atmosphere'+path
        log.debug "connection added . mapping-> $mapping"
        Broadcaster b = BroadcasterFactory.getDefault().lookup(SimpleBroadcaster.class,mapping, true)
        Meteor m = Meteor.build(request)
        m.addListener(new AtmosphereResourceEventListenerAdapter())
        m.setBroadcaster(b)
        m.resumeOnBroadcast((m.transport() == LONG_POLLING)).suspend(25, TimeUnit.SECONDS)
    }
}

All is working fine with atmosphere with this configuration but when i go to tomcat logs i see this error every 25 seconds:

_org.apache.catalina.core.AsyncContextImpl timeout
WARNING: onTimeout() failed for listener of type [org.apache.catalina.core.AsyncListenerWrapper]
java.lang.IllegalStateException: Calling [asyncComplete()] is not valid for a request with Async state [MUST_COMPLETE]
_

_I am using tomcat version 7.0.50._

I have newrelic to track events from my webserver and because of this i realised was happening a lot. The strangest thing is that in tomcat logs is mentioned as a warning but arrives to newrelic as an error. Perhaps it is something in the newrelic configuration.

Do you know if we could set a timeout to 25 seconds for Async context or should we do something else in AppMeteorHandler?

Thanks in advanced!
Sebastian

@jfarcand jfarcand changed the title MeteorServlet Async Context [Tomcat] onTimeout() failed for listener of type [org.apache.catalina.core.AsyncListenerWrapper] java.lang.IllegalStateException: Calling [asyncComplete()] is not valid for a request with Async state [MUST_COMPLETE] Nov 12, 2014
jfarcand added a commit that referenced this issue Nov 12, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant