使用cometD的Oort和tomcat

时间:2013-10-25 07:33:50

标签: java tomcat asynchronous cometd

我们正在使用带有Tomcat 7.0.42的cometD(这是必须的)。我们现在尝试让Oort(cometD的集群机制)工作。如果我像这样在web.xml中启用了Oort,每次另一个节点尝试连接下面发生的异常时都会发生。

我很清楚cometD目前无法使用带有Tomcat的Websockets,这就是为什么我会认为cometD只是回归到longpolling ......

这是我的配置:

  <web-app xmlns="http://java.sun.com/xml/ns/javaee"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     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>messenger</display-name>

<servlet>
    <servlet-name>cometd</servlet-name>
    <servlet-class>org.cometd.server.CometdServlet</servlet-class>
    <init-param>
        <param-name>allowedTransports</param-name>
        <param-value>LongPollingTransport</param-value>
    </init-param>
    <init-param>
        <param-name>timeout</param-name>
        <param-value>20000</param-value>
    </init-param>


    <init-param>
        <param-name>jsonContext</param-name>
        <param-value>org.cometd.server.JacksonJSONContextServer</param-value>
    </init-param>
    <init-param>
        <param-name>maxInterval</param-name>
        <param-value>10000</param-value>
    </init-param>

    <init-param>
        <param-name>long-polling.multiSessionInterval</param-name>
        <param-value>2000</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
    <async-supported>true</async-supported>
</servlet>

<servlet-mapping>
    <servlet-name>cometd</servlet-name>
    <url-pattern>/cometd/*</url-pattern>
</servlet-mapping>

<servlet>
    <servlet-name>Oort</servlet-name>
    <servlet-class>org.cometd.oort.OortStaticConfigServlet</servlet-class>
    <init-param>
        <param-name>oort.url</param-name>
        <param-value>http://192.168.178.37:8080/messenger/cometd</param-value>
    </init-param>
    <init-param>
        <param-name>oort.channels</param-name>
        <param-value>/messenger/**,/internal/**</param-value>
    </init-param>
    <init-param>
        <param-name>oort.cloud</param-name>
        <param-value>http://192.168.178.22:8080/messenger/cometd</param-value>
    </init-param>
    <load-on-startup>2</load-on-startup>
    <async-supported>true</async-supported>
</servlet>

<servlet>
    <servlet-name>Seti</servlet-name>
    <servlet-class>org.cometd.oort.SetiServlet</servlet-class>
    <load-on-startup>3</load-on-startup>
    <async-supported>true</async-supported>
</servlet>

这是例外:

org.cometd.common.TransportException: {httpCode=400, websocketCode=1002}
at org.cometd.websocket.client.WebSocketTransport.connect(WebSocketTransport.java:287) ~[cometd-websocket-jetty-2.7.0.jar:na]
at org.cometd.websocket.client.WebSocketTransport.send(WebSocketTransport.java:194) ~[cometd-websocket-jetty-2.7.0.jar:na]
at org.cometd.client.BayeuxClient$BayeuxClientState.send(BayeuxClient.java:1390) ~[cometd-java-client-2.7.0.jar:na]
at org.cometd.client.BayeuxClient.sendHandshake(BayeuxClient.java:374) ~[cometd-java-client-2.7.0.jar:na]
at org.cometd.client.BayeuxClient$HandshakingState.execute(BayeuxClient.java:1496) ~[cometd-java-client-2.7.0.jar:na]
at org.cometd.client.BayeuxClient.updateBayeuxClientState(BayeuxClient.java:1062) ~[cometd-java-client-2.7.0.jar:na]
at org.cometd.client.BayeuxClient.handshake(BayeuxClient.java:315) ~[cometd-java-client-2.7.0.jar:na]
at org.cometd.oort.Oort.connectComet(Oort.java:411) ~[cometd-java-oort-2.7.0.jar:na]
at org.cometd.oort.Oort.observeComet(Oort.java:358) ~[cometd-java-oort-2.7.0.jar:na]
at org.cometd.oort.Oort.observeComet(Oort.java:306) ~[cometd-java-oort-2.7.0.jar:na]
at org.cometd.oort.OortMulticastConfigurer.receive(OortMulticastConfigurer.java:125) ~[cometd-java-oort-2.7.0.jar:na]
at org.cometd.oort.OortMulticastConfigurer$MulticastReceiver.run(OortMulticastConfigurer.java:154) ~[cometd-java-oort-2.7.0.jar:na]
at java.lang.Thread.run(Thread.java:724) ~[na:1.7.0_25]

Caused by: java.net.ProtocolException: Bad response status 400 Bad Request
at org.eclipse.jetty.websocket.WebSocketClientFactory$HandshakeConnection.onClose(WebSocketClientFactory.java:546) ~[jetty-websocket-8.1.5.v20120716.jar:8.1.5.v20120716]
at org.eclipse.jetty.websocket.WebSocketClientFactory$WebSocketClientSelector.endPointClosed(WebSocketClientFactory.java:326) ~[jetty-websocket-8.1.5.v20120716.jar:8.1.5.v20120716]
at org.eclipse.jetty.io.nio.SelectorManager$SelectSet.destroyEndPoint(SelectorManager.java:848) ~[jetty-io-8.1.5.v20120716.jar:8.1.5.v20120716]
at org.eclipse.jetty.io.nio.SelectChannelEndPoint.doUpdateKey(SelectChannelEndPoint.java:601) ~[jetty-io-8.1.5.v20120716.jar:8.1.5.v20120716]
at org.eclipse.jetty.io.nio.SelectorManager$SelectSet.doSelect(SelectorManager.java:463) ~[jetty-io-8.1.5.v20120716.jar:8.1.5.v20120716]
at org.eclipse.jetty.io.nio.SelectorManager$1.run(SelectorManager.java:285) ~[jetty-io-8.1.5.v20120716.jar:8.1.5.v20120716]
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:603) ~[jetty-util-8.1.5.v20120716.jar:8.1.5.v20120716]
at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:538) ~[jetty-util-8.1.5.v20120716.jar:8.1.5.v20120716]
... 1 common frames omitted

2 个答案:

答案 0 :(得分:0)

您看到的错误报告webSocketCode=1002,并且执行此操作的代码会禁用WebSocket传输,因此回退到长轮询应该可以正常运行。

CometD测试套件对这种情况进行了测试。

答案 1 :(得分:-1)

所以这只是一个调试消息而不是必须显示“真正的”异常?