我有一个WebSocket应用程序,该程序以编程方式注册了端点,而没有使用注释。
相关代码为:ServerEndpointConfig.Configurator configurator =
(ServerEndpointConfig.Configurator)configuratorClass.newInstance();
ServerEndpointConfig serverEndpointConfig = ServerEndpointConfig.Builder
.create(endpointClass, endpointPath)
.configurator(configurator)
.build();
ServerContainer serverContainer = (ServerContainer)app
.getServletContext()
.getAttribute("javax.websocket.server.ServerContainer");
serverContainer.addEndpoint(serverEndpointConfig);
当我在带有嵌入式Jetty容器的IDE中运行它时,一切工作正常,其中依赖关系通过Maven在tomcat-websocket和tomcat-websocket-api库上,但是当我在Tomcat(8.5.5)中部署它,然后尝试建立WebSocket连接,在浏览器的控制台中出现以下错误:WebSocket与“ ws://127.0.0.1:8080 / echo”的连接失败:WebSocket握手期间出错:意外的响应代码:500
我在Catalina输出中未记录任何错误或其他信息,并且不确定如何调试此问题。
我需要以编程方式配置端点,因为在编译时尚不了解许多信息,因此请不要将我指向注释解决方案。
我已将日志级别设置为FINE,这是相关的代码段:T.550 FINE [http-nio-IP-Acceptor-0] o.a.tomcat.util.threads.LimitLatch.countUpOrAwait Counting up[http-nio-IP-Acceptor-0] latch=2
T.551 FINE [http-nio-IP-exec-3] o.a.coyote.AbstractProtocol$ConnectionHandler.process Processing socket [o.a.tomcat.util.net.NioChannel@1e87b268:java.nio.channels.SocketChannel[connected local=/192.168.1.17:8080 remote=/192.168.1.17:51259]] with status [OPEN_READ]
T.551 FINE [http-nio-IP-exec-3] o.a.coyote.http11.Http11InputBuff