简体   繁体   English

如何将 Web 套接字从 Internet Web 应用程序发送到本地服务器

[英]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.

相关问题 如何从Linux服务器Java Web应用程序访问本地路径? - How to access local path from linux server java web application? 如何录制声音并将其从 web 应用程序发送到服务器? - How do I record sound and send it to a server from a web application? 从服务器向 Web 应用程序发送请求 - send request from server to web application web 服务器在本地 web 应用程序中的用途是什么? - What is the purpose of web server in a local web application? 如何将数据从Web发送到Linux服务器 - How to send data from web to linux server 如何在Eclipse中使用带有嵌入式WTP插件的Jetty服务器使用Web套接字编写客户端服务器应用程序 - How to write client server application with web sockets using jetty server with embedded wtp plugin in eclipse 从Web应用程序发送短信 - send sms from web application Android应用程序(客户端)可以使用套接字与Java Web服务器通信吗? - Can an android application(client) communicate with a java web server using sockets? 如何使用Eclipse在本地服务器上的GitHub上运行Web应用程序? - How i can run web-application from GitHub on local server using Eclipse? 如何在Web应用程序中获取服务器本地驱动器路径? - How to get server local drive path in web application?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM