如何在tomcat 6上启用NIO /氛围

时间:2012-08-26 12:10:23

标签: java tomcat atmosphere

我正在尝试tomcat 6上的氛围,但只有长轮询工作不是websockets。我在控制台输出中收到的消息是

 Tomcat failed to detect this is a Comet application because context.xml is missing or the Http11NioProtocol Connector is not enabled.

有关此的任何信息将不胜感激,谢谢

更新:修改web.xml和server.xml之后会出现错误消息,但是聊天应用程序总是回退到长轮询 - 我尝试了几个不同的.war部署的websocket演示,它们都是表现相同。

我也尝试过Tomcat 7,但它仍然使用长轮询。

启动的一些日志信息

10:42:30.423 [main] INFO  o.atmosphere.cpr.AtmosphereFramework - Installed Default AtmosphereInterceptor [Android Interceptor Support, SSE Interceptor Support, JSONP Interceptor Support]. Set org.atmosphere.cpr.AtmosphereInterceptor.disableDefaults in your xml to disable them.
10:42:30.423 [main] WARN  o.atmosphere.cpr.AtmosphereFramework - No BroadcasterCache configured. Broadcasted message between client reconnection will be LOST. It is recommended to configure the HeaderBroadcasterCache.
10:42:30.423 [main] INFO  o.atmosphere.cpr.AtmosphereFramework - HttpSession supported: false
10:42:30.423 [main] INFO  o.atmosphere.cpr.AtmosphereFramework - Using BroadcasterFactory: org.atmosphere.cpr.DefaultBroadcasterFactory
10:42:30.423 [main] INFO  o.atmosphere.cpr.AtmosphereFramework - Using WebSocketProcessor: org.atmosphere.websocket.DefaultWebSocketProcessor
10:42:30.423 [main] INFO  o.atmosphere.cpr.AtmosphereFramework - Using Broadcaster: org.atmosphere.jersey.JerseyBroadcaster
10:42:30.428 [main] INFO  o.atmosphere.cpr.AtmosphereFramework - Atmosphere Framework 1.0.0.beta5 started.

27/08/2012 10:42:30 AM org.apache.coyote.http11.Http11NioProtocol start
INFO: Starting Coyote HTTP/1.1 on http-8080
27/08/2012 10:42:30 AM org.apache.catalina.startup.Catalina start
INFO: Server startup in 11568 ms

聊天客户端连接时

27/08/2012 10:47:57 AM org.apache.tomcat.util.net.NioSelectorPool getSharedSelector

信息:使用共享选择器进行servlet写入/读取

发送消息时

10:48:09.256 [http-8080-exec-2] DEBUG o.a.cpr.AsynchronousProcessor - Cancelling the connection for request AtmosphereRequest{ contextPath=/atmosphere-rest-chat servletPath=/chat pathInfo=null requestURI=/atmosphere-rest-chat/chat requestURL=http://mogwai:8080/atmosphere-rest-chat/chat destroyable=true}

1 个答案:

答案 0 :(得分:1)

在context.xml中:

<?xml version="1.0" encoding="UTF-8"?>
<Context>
    <Loader delegate="true"/>
</Context>

在server.xml中:

<Connector connectionTimeout="20000" port="8080" 
           protocol="org.apache.coyote.http11.Http11NioProtocol" 
           redirectPort="8443"/>

确保在类路径中只定义了一个CometProcessor实现。你可能想要从你的webpass中删除catalina.jar(如果它已捆绑)。有关详细信息,请参阅此主题:

http://mail-archives.apache.org/mod_mbox/tomcat-users/200707.mbox/%3C11785700.post@talk.nabble.com%3E