简体   繁体   English

通过Apache和Tomcat 500的WebSocket错误:java.lang.UnsupportedOperationException:该协议不支持HTTP升级

[英]WebSocket through Apache and Tomcat 500 Error : java.lang.UnsupportedOperationException: HTTP upgrade is not supported by this protocol

I was implementing Web Socket using JavaScript on the client and Java/Tomcat on the server. 我在客户端上使用JavaScript并在服务器上使用Java / Tomcat来实现Web Socket。 It works very fine on localhost but when I deploy on my remote host it fails. 它在localhost上可以很好地工作,但是当我在远程主机上部署它失败。 Checking the console, I get 500 error on the Web socket request. 检查控制台,Web套接字请求出现500错误。 Hence i check the server error log to view the error and find - 因此,我检查服务器错误日志以查看错误并查找-

java.lang.UnsupportedOperationException: HTTP upgrade is not supported by this protocol
    at org.apache.coyote.AbstractProcessor.doHttpUpgrade(AbstractProcessor.java:712) ~[tomcat-coyote.jar:8.5.20]
    at org.apache.coyote.AbstractProcessor.action(AbstractProcessor.java:478) ~[tomcat-coyote.jar:8.5.20]
    at org.apache.coyote.Request.action(Request.java:433) ~[tomcat-coyote.jar:8.5.20]
    at org.apache.catalina.connector.Request.upgrade(Request.java:2022) ~[catalina.jar:8.5.20]
    at org.apache.catalina.connector.RequestFacade.upgrade(RequestFacade.java:1115) ~[catalina.jar:8.5.20]
    at org.apache.tomcat.websocket.server.UpgradeUtil.doUpgrade(UpgradeUtil.java:234) ~[tomcat-websocket-8.5.20.jar:8.5.20]
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:77) ~[tomcat-websocket-8.5.20.jar:8.5.20]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[catalina.jar:8.5.20]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[catalina.jar:8.5.20]
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198) [catalina.jar:8.5.20]
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96) [catalina.jar:8.5.20]
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:478) [catalina.jar:8.5.20]
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140) [catalina.jar:8.5.20]
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:80) [catalina.jar:8.5.20]
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87) [catalina.jar:8.5.20]
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342) [catalina.jar:8.5.20]
    at org.apache.coyote.ajp.AjpProcessor.service(AjpProcessor.java:486) [tomcat-coyote.jar:8.5.20]
    at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66) [tomcat-coyote.jar:8.5.20]
    at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:868) [tomcat-coyote.jar:8.5.20]
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1457) [tomcat-coyote.jar:8.5.20]
    at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) [tomcat-coyote.jar:8.5.20]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [?:1.8.0_11]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [?:1.8.0_11]
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) [tomcat-util.jar:8.5.20]
    at java.lang.Thread.run(Thread.java:745) [?:1.8.0_11]

I did some research and stumbled on someone who had a similar problem and asked in this question WebSockets through Apache and Tomcat: HTTP upgrade is not supported by the AJP protocol but am running a private tomcat instance on a shared hosting server so the solutions provided in that answer cannot be achieved by me hence i contact my host and they respond with 我做了一些研究,偶然发现一个有类似问题的人,并通过Apache和Tomcat询问了WebSockets:AJP协议不支持HTTP升级,但正在共享托管服务器上运行私有tomcat实例,因此提供了解决方案。该答案无法由我解决,因此我联系了我的房东,他们以

'While investigating your query, we could see that making changes in the tomcat and HTTP settings as per the steps mentioned in your email will affect the AJP connection configuration of another shared tomcat instance and the applications hosted by the shared tomcat instance will not work. '在调查查询时,我们可以看到,按照电子邮件中提到的步骤对tomcat和HTTP设置进行更改将影响另一个共享tomcat实例的AJP连接配置,并且由共享tomcat实例托管的应用程序将无法正常工作。 For re-compiling, the connector settings also need a server-wide update and this cannot be done in a shared server environment. 对于重新编译,连接器设置还需要在服务器范围内进行更新,而这不能在共享服务器环境中完成。 We request you to try our VPS plans by visiting the below link.' 我们要求您通过访问以下链接来尝试我们的VPS计划。”

I think purchasing a vps plan should be a last resort. 我认为购买vps计划应该是万不得已的方法。 Is there anyone here with a more conducive solution to the problem. 这里有没有人对这个问题有更有利的解决方案。

You need VPS in this case. 在这种情况下,您需要VPS。 The last I've purchased was hetzner, they provide new plans with less powerful CPU or something like this, so I get 4gb RAM server for 5.88 USD / month, 1gb for 2.99 我上次购买的产品是hetzner,它们提供了功能更弱的CPU或类似功能的新计划,所以我以每月5.88美元的价格获得4GB的RAM服务器,以2.99美元的价格获得1GB的服务

One option is to work with Spring boot and embedded tomcat. 一种选择是使用Spring Boot和嵌入式tomcat。 So you are able to configure your own embedded instance of Tomcat. 因此,您可以配置自己的Tomcat嵌入式实例。

Here is a oint to start with: Spring with embedded Webserver 首先要介绍的内容: 带有嵌入式Web服务器的Spring

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Nodejs 错误:不支持协议“http:”。 预期“https:” - Nodejs Error: Protocol “http:” not supported. Expected “https:” 节点 js 错误:不支持协议“https:”。 预期“http:” - Node js Error: Protocol "https:" not supported. Expected "http:" CORS 错误:“请求仅支持协议方案:http…”等 - CORS Error: “requests are only supported for protocol schemes: http…” etc 获取 HTTP 状态 500 ? 将 tomcat 7 升级到 8 时出现内部服务器错误 - Getting HTTP Status 500 ? Internal Server Error while upgrading tomcat 7 to 8 websocket:客户端未使用 websocket 协议:“连接”中未找到“升级”令牌 header - websocket: the client is not using the websocket protocol: 'upgrade' token not found in 'Connection' header tomcat 7.0.50 java websocket实现给出了404错误 - tomcat 7.0.50 java websocket implementation gives 404 error WebSocket 关闭并出现协议错误 1002 - WebSocket Closes with Protocol Error 1002 不在Tomcat中连接到Java websocket - Does not connect to Java websocket in Tomcat React - 不支持协议“https:”。 预期的“http:” - React - Protocol "https:" not supported. Expected "http:" WebSocket握手期间出错:缺少“升级”标头(Apache 2.4 + mod_proxy_wstunnel) - Error during WebSocket handshake: 'Upgrade' header is missing (Apache 2.4 + mod_proxy_wstunnel)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM