[英]How to send web sockets from an internet web application to a local server
I'm developing a web application called myWebApp using Spring MVC, myWebApp is deployed on a remote server in the internet.我正在使用 Spring MVC 开发一个名为 myWebApp 的 Web 应用程序,myWebApp 部署在 Internet 中的远程服务器上。 I want to use MyWebApp to communicate with a server using TCP socket via local browser and the TCP server is located in the local network.
我想使用 MyWebApp 通过本地浏览器与使用 TCP 套接字的服务器进行通信,并且 TCP 服务器位于本地网络中。
I'm aware of the usage of Websockets but how can I send commands from web browser to the server located in the intranet network.我知道 Websockets 的使用,但是如何从 Web 浏览器向位于 Intranet 网络中的服务器发送命令。 Do you have any solution please.
请问您有什么解决办法吗。
Application flow is pictured below:申请流程如下图:
You can do this by some port forwarding applications that are available.您可以通过一些可用的端口转发应用程序来做到这一点。 But they use their own sites to access it from internet.
但是他们使用自己的网站从互联网上访问它。 You could try https://ngrok.com/ or similar softwares.
您可以尝试https://ngrok.com/或类似软件。 That will give access to your locally running applications from internet.
这将允许从 Internet 访问您本地运行的应用程序。
It doesn't seem to have anything to do with websockets, or sockets.它似乎与 websockets 或套接字没有任何关系。 You are blocked behind NAT of the router in the intranet network.
您被阻止在 Intranet 网络中路由器的 NAT 后面。 Check PORT FORWARDING configuration of your router and forward the public port that socket uses to private ip and port of the server machine.
检查你的路由器的端口转发的配置和转发公共端口插孔是用来在服务器计算机的私有IP和端口。
I don't understand where is browser in your architecture.我不明白您的架构中的浏览器在哪里。 Navigator and TCP/IP server can easily talk to each other using local ip address.
Navigator 和 TCP/IP 服务器可以使用本地 IP 地址轻松地相互通信。 You spring webApp tho needs to know which server to talk to in your local network.
您使用 spring webApp 需要知道要与本地网络中的哪个服务器通信。 So, public address of your local network is not enough.
因此,您本地网络的公共地址是不够的。 It needs know which local machine to connect to.
它需要知道要连接到哪台本地机器。
If your ip address is dynamic, use services like noip.com or buy a domain and point it to your ip address.如果您的 IP 地址是动态的,请使用noip.com等服务或购买域并将其指向您的 IP 地址。 This way by using your domain name in your application, you dont have to worry about ip address changing...
这样通过在您的应用程序中使用您的域名,您不必担心 ip 地址更改...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.