本文介绍了使用Netty将Websockets与运行在Tomcat中的Spring Web应用程序集成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用Netty的Web套接字服务器实现(例如侦听8081端口),以及一个单独的在Tomcat中运行的Spring Web应用程序(在80端口运行).

I have a web socket server implementation using Netty (say listening on port 8081) and a separate Spring web application running in Tomcat (running in port 80).

我想以某种方式将所有来自localhost:80/Websocket的请求转发到端口8081上的我的Netty服务器.这完全有可能吗?由于Tomcat和spring是基于http协议构建的,因此idk怎么可能.

I would like to somehow forward all request coming to localhost:80/Websocket to my Netty server on port 8081. Is this possible at all. since Tomcat and spring is build on top of http protocol, idk how this would be possible.

我要做的就是使用现有Spring Web应用程序中的websocket启用服务器推送.有什么建议吗?

All I wanted to do is enable server push using websocket from my existing spring web app. Any suggestions?

推荐答案

最简单的方法可能是将nginx服务器放在最前面,并将其转发到/Websockets,但是因为Websockets不是Http 1.0,所以您不能使用正常的ProxyPass指令,但要符合 http://www.letseehere.com/reverse-proxy-网络套接字可以通过特殊的插件

The easiest way would probably be to put an nginx server up front and have it forward requests to /Websockets, however because Websockets is not Http 1.0 you can't use normal ProxyPass directives but according to http://www.letseehere.com/reverse-proxy-web-sockets it's possible via a special plugin

这篇关于使用Netty将Websockets与运行在Tomcat中的Spring Web应用程序集成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-05 08:59