开发者

TCP Client/Server considering adding an intermediary

开发者 https://www.devze.com 2023-02-16 17:26 出处:网络
Currently I have mobile users that act as clients, and they can connect to their home computers via a running server on that computer.

Currently I have mobile users that act as clients, and they can connect to their home computers via a running server on that computer.

Problem is, there're issues with dynamic IP addresses and port forwarding.

I've thought about NAT traversal, but that doesn't work in all instances.

Ideally, I'd like them to just put a username and password in the mobile app and as parameters to the server on startup, and have them both communicate with my intermediary server hosted elsewhere. That way they don't have to bother with any of that.

Problem is, their running server won't know when the mobile app is requesting information in this scenario, or what to respond with.

So I'm looking for implementation suggestions or alternatives. Really, anything would be appre开发者_开发百科ciated.


If I correctly understand the problem, a client wants to contact to home computer that is behind a NAT device. If so, this is common problem for VoIP technologies. There are known relyable ways to get around the dynamic IP addresses and NAT. Specifically for dealind with NAT problem, two technologies, based on UDP Hole Punching are STUN and ICE.

If your solution is not for VoIP, you can still use UDP Hole Punching technique to get real-time connectivity with a computer behind a NAT --- and you don't have to have a STUN/ICE servers, but you will have to know a lot about NAT/routing and different types of NAT devices.


Hole punching is pretty worthless when both server and client is behind a firewall/router, or in this case when the client is on a dynamic IP and the server is behind a firewall/router.

Using a middle man server as you suggested is the proper way to go. And I do not really understand the problem. Let the user register an account at your server and have him specify that account both at the local server and in the phones. Then let both the local server and the phones connect to your server with the provided account.

By doing so your internet server knows which local server to forward the phone requests to.


If the home computer connects to your server hosted elsewhere, you can just have it so it maintains that connection, and whenever the mobile app communicates with it, it'll send a message to the home computer, since the connection should be alive for as long as the home user has that program running.

0

精彩评论

暂无评论...
验证码 换一张
取 消