0

我在 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 后,错误消息消失,但聊天应用程序总是回退到长轮询 - 我尝试了几种不同的 websocket 演示的 .war 部署,它们的行为都相同。

我也试过 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}
4

1 回答 1

1

在 context.xml 中:

<?xml 版本="1.0" 编码="UTF-8"?>
<上下文>
    <加载程序委托="true"/>
</上下文>

在 server.xml 中:

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

确保在类路径中只定义了一个 CometProcessor 实现。如果捆绑了 catalina.jar,您可能希望从您的 webpass 中删除它。有关更多信息,请参阅此线程:

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

于 2012-08-26T12:25:28.967 回答