如何通过apache2启用到websocket的连接?

bd1hkmkf  于 2021-10-10  发布在  Java
关注(0)|答案(0)|浏览(395)

我在apache2 websocket的一期杂志上发表了4天的文章。我在ApacheTomcat10上部署了一个连接到spring启动应用程序的SockJSWebSocket。下面是部署在tomcat上的sockjs代码。

var urlToCall='http://192.168.50.130:8082/MyWebsocket';
            console.log('calling '+urlToCall);
           websocket = new SockJS(urlToCall);

sockjs应用程序托管在dc文件夹下,因此当我访问http://192.168.50.130:8080/dc/ .与websocket的连接已建立良好。
现在,我将apache2配置为将所有请求转发到tomcat one:
以下是apache2(000 default.conf)的配置

<VirtualHost *:80> 
  ProxyPreserveHost On 

ProxyRequests Off
   ProxyPass /  http://192.168.50.130:8080/dc/ nocanon
     ProxyPassReverse /   http://192.168.50.130:8080/dc/

ProxyPass "/ws/"  "ws://192.168.50.130:8082/"
ProxyPass "/wss/"  "wss://192.168.50.130:8082/"

</VirtualHost>

不幸的是,它说总是无法连接到服务器。

这是apache2服务器的完整日志

[Sun Jul 04 11:49:33.851557 2021] [authz_core:debug] [pid 39624:tid 139862925604608] mod_authz_core.c(845): [client 192.168.50.1:59050] AH01628: authorization result: granted (no directives)
[Sun Jul 04 11:49:33.851650 2021] [proxy:debug] [pid 39624:tid 139862925604608] mod_proxy.c(1253): [client 192.168.50.1:59050] AH01143: Running scheme http handler (attempt 0)
[Sun Jul 04 11:49:33.851659 2021] [proxy_ajp:debug] [pid 39624:tid 139862925604608] mod_proxy_ajp.c(743): [client 192.168.50.1:59050] AH00894: declining URL http://192.168.50.130:8080/dc/
[Sun Jul 04 11:49:33.851665 2021] [proxy:debug] [pid 39624:tid 139862925604608] proxy_util.c(2325): AH00942: HTTP: has acquired connection for (192.168.50.130)
[Sun Jul 04 11:49:33.851670 2021] [proxy:debug] [pid 39624:tid 139862925604608] proxy_util.c(2379): [client 192.168.50.1:59050] AH00944: connecting http://192.168.50.130:8080/dc/ to 192.168.50.130:8080
[Sun Jul 04 11:49:33.851675 2021] [proxy:debug] [pid 39624:tid 139862925604608] proxy_util.c(2588): [client 192.168.50.1:59050] AH00947: connected /dc/ to 192.168.50.130:8080
[Sun Jul 04 11:49:33.851715 2021] [proxy:debug] [pid 39624:tid 139862925604608] proxy_util.c(2889): AH00951: HTTP: backend socket is disconnected.
[Sun Jul 04 11:49:33.851820 2021] [proxy:debug] [pid 39624:tid 139862925604608] proxy_util.c(3054): AH02824: HTTP: connection established with 192.168.50.130:8080 (192.168.50.130)
[Sun Jul 04 11:49:33.851831 2021] [proxy:debug] [pid 39624:tid 139862925604608] proxy_util.c(3240): AH00962: HTTP: connection complete to 192.168.50.130:8080 (192.168.50.130)
[Sun Jul 04 11:49:33.853253 2021] [proxy:debug] [pid 39624:tid 139862925604608] proxy_util.c(2340): AH00943: http: has released connection for (192.168.50.130)
[Sun Jul 04 11:49:33.853450 2021] [deflate:debug] [pid 39624:tid 139862925604608] mod_deflate.c(854): [client 192.168.50.1:59050] AH01384: Zlib: Compressed 747 to 323 : URL /
[Sun Jul 04 11:49:34.041340 2021] [authz_core:debug] [pid 39624:tid 139863076226816] mod_authz_core.c(845): [client 192.168.50.1:59050] AH01628: authorization result: granted (no directives)
[Sun Jul 04 11:49:34.041987 2021] [proxy:debug] [pid 39624:tid 139863076226816] mod_proxy.c(1253): [client 192.168.50.1:59050] AH01143: Running scheme http handler (attempt 0)
[Sun Jul 04 11:49:34.042029 2021] [proxy_ajp:debug] [pid 39624:tid 139863076226816] mod_proxy_ajp.c(743): [client 192.168.50.1:59050] AH00894: declining URL http://192.168.50.130:8080/dc/jsterm/js/sockjs.js.map
[Sun Jul 04 11:49:34.042039 2021] [proxy:debug] [pid 39624:tid 139863076226816] proxy_util.c(2325): AH00942: HTTP: has acquired connection for (192.168.50.130)
[Sun Jul 04 11:49:34.042046 2021] [proxy:debug] [pid 39624:tid 139863076226816] proxy_util.c(2379): [client 192.168.50.1:59050] AH00944: connecting http://192.168.50.130:8080/dc/jsterm/js/sockjs.js.map to 192.168.50.130:8080
[Sun Jul 04 11:49:34.042053 2021] [proxy:debug] [pid 39624:tid 139863076226816] proxy_util.c(2588): [client 192.168.50.1:59050] AH00947: connected /dc/jsterm/js/sockjs.js.map to 192.168.50.130:8080
[Sun Jul 04 11:49:34.053306 2021] [proxy:debug] [pid 39624:tid 139863076226816] proxy_util.c(2340): AH00943: http: has released connection for (192.168.50.130)
[Sun Jul 04 11:49:34.054368 2021] [deflate:debug] [pid 39624:tid 139863076226816] mod_deflate.c(854): [client 192.168.50.1:59050] AH01384: Zlib: Compressed 214061 to 46910 : URL /jsterm/js/sockjs.js.map

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题