我刚刚在 ElasticBeanstalk 上设置了我的 Web 应用程序。一切似乎都运行良好,直到我发现我的实例无法使用 WebSocket,每次我尝试连接时都会返回内部服务器错误代码。
当我检查日志时,我发现 NullPointerException 不太可能是由我引起的。以下是堆栈跟踪:
Aug 27, 2013 5:01:18 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [WebSocketChannel] in context with path [] threw exception
java.lang.NullPointerException
at org.apache.catalina.websocket.WebSocketServlet.getWebSocketAccept(WebSocketServlet.java:171)
at org.apache.catalina.websocket.WebSocketServlet.doGet(WebSocketServlet.java:116)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:225)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
at org.apache.catalina.valves.RemoteIpValve.invoke(RemoteIpValve.java:680)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:927)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:999)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:565)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:309)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:679)
我的实例正在运行版本 7.0.27。当我检查 tomcat 的源代码以查找问题根源时,我什么也不明白。
有什么想法导致问题的原因吗? WebSockets 不适用于 ElasticBeanstalk 和 Apache Tomcat 吗?
答案1
Websockets 需要 tomcat 7.0.47 或 8,另外请确保您有 JRE 7,还有一件事要检查您的 ELB 是否在 TCP/SSL 级别配置,而不是 HTTP/HTTPS