gpt4 book ai didi

java - 将 cometD 的奥尔特与 tomcat 一起使用

转载 作者:行者123 更新时间:2023-11-28 23:56:04 24 4
gpt4 key购买 nike

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

我很清楚 cometD 目前不能将 Websockets 与 Tomcat 一起使用,这就是为什么我希望 cometD 简单地退回到长轮询...

这是我的配置:

  <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>

这是个异常(exception):

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

最佳答案

您看到的错误报告是 webSocketCode=1002,执行此操作的代码会禁用 WebSocket 传输,因此回退到长轮询应该可以完美地工作。

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

关于java - 将 cometD 的奥尔特与 tomcat 一起使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19583809/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com