开发者

Missing comet events on Tomcat 7 CometProcessor

开发者 https://www.devze.com 2023-01-14 18:02 出处:网络
I am using CometProcessor to implement long-polling on Tomcat 7.0. The thing that bothering me is I don\'t get any other events except CometEvent.EventType.BEGIN.

I am using CometProcessor to implement long-polling on Tomcat 7.0. The thing that bothering me is I don't get any other events except CometEvent.EventType.BEGIN. The code sample:

    @Override
    public void event(CometEvent event) throws IOException, ServletException {

    HttpServletRequest request = event.getHttpServletRequest();
    HttpServletResponse response = event.getHttpServletResponse();
    if (event.getEventType() == CometEvent.EventType.BEGIN) {
        LOGGER.info("Begin for session: " + request.getSession(true).getId());
    } else if (event.getEventType() == CometEvent.Event开发者_StackOverflow中文版Type.ERROR) {
        LOGGER.error("Error for session: " + request.getSession(true).getId());
        event.close();
    } else if (event.getEventType() == CometEvent.EventType.END) {
        LOGGER.info("End for session: " + request.getSession(true).getId());
        event.close();
    } else if (event.getEventType() == CometEvent.EventType.READ) {
        LOGGER.info("Read from session: " + request.getSession(true).getId());
    }

I assume it could cause memory leaks because on the BEGIN event I store the response object in my local array.

Does any one have any ideas what could be wrong?


Seems there is nothing to invoke the request end so it will just sit there until a timeout occurs. In my experience, END is triggered when you call close, outside the context of the thread that calls begin.

0

精彩评论

暂无评论...
验证码 换一张
取 消