我在使用 Apache 24 的 Tomcat 中推送 primefaces 时遇到问题。
下面是显示的错误:
java.lang.UnsupportedOperationException: HTTP upgrade is not supported by the AJP protocol
下面是 web chrome 控制台中的错误
WebSocket connection to 'wss://myhost.com/primepush/customers/org?X-…ransport=websocket&X-Atmosphere-TrackMessageSize=true&X-atmo-protocol=true' failed: Error during WebSocket handshake: Unexpected response code: 500
Websocket closed, reason: Connection was closed abnormally (that is, with no close frame being sent). - wasClean: false
Websocket failed on first connection attempt. Downgrading to long-polling and resending
我读到 AJP 协议不支持升级到其他协议(例如 websocket、HTTP/2)。而且我可能需要设置我的反向代理,但我对如何正确设置它有点困惑。有人有这方面的经验吗?
注意:如果我不使用 Apache 而只是直接使用普通 HTTP,这是可行的。
此 ws 的当前反向代理设置:
LoadModule proxy_wstunnel_module modules/mod_proxy_wstunnel.so
ProxyPass /primepush/ ws://localhost:8080/primepush/
ProxyPassReverse /primepush/ ws://localhost:8080/primepush/
我还在我的 tomcat 中添加了连接器
<Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" />
发现上述设置错误:
AH01144: No protocol handler was valid for the URL /primepush/customers....
make sure the proxy submodules are included in the configuration using LoadModule.
以下是 ws 模块状态:
proxy_wstunnel_module (shared)
我还发现了奇怪的事情:
- 当我第一次进入有此推送的页面时(使用链接)它工作正常,日志中没有错误,控制台 web 中也没有错误。推也正常工作。
- 但是当我刷新该页面时,控制台和error.log 中都会出现错误。在网络中它显示 GET https://myhost.com/primepush ... 505 错误。它还在 chrome 控制台中显示此警告:主线程上的同步 XMLHttpRequest 已被弃用,因为它对最终用户的体验产生不利影响。
附加信息:推送仍在工作,没有消息表明它会降低投票等级,但我真的很关心这个错误的根本原因是什么以及它会产生什么影响。