简体   繁体   中英

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. 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.

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. 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. That will give access to your locally running applications from internet.

It doesn't seem to have anything to do with websockets, or sockets. You are blocked behind NAT of the router in the intranet network. Check PORT FORWARDING configuration of your router and forward the public port that socket uses to private ip and port of the server machine.

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. You spring webApp tho needs to know which server to talk to in your local network. 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. This way by using your domain name in your application, you dont have to worry about ip address changing...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM