I am trying to connect two Windows applications running on different computers not on the same subnet using Delphi's (10.3.1) app tethering. If the originating computer has both a public IP address and a local IP address, the responding computer seems to reply using the originator’s local IP address, which fails. I have tried it on 3 different computers -- an Amazon Web Services (AWS) EC2 Windows server instance (it has both a public and private IP), a Windows 10 computer with both a public (static) and private IP, and a Windows 10 computer that has only a local IP but with port forwarding setup on the router to route UDP/TCP ports 2020-2100 to it -- and each fails in the same way. It is not an issue with packets getting blocked -- I have opened up the relevant UDP/TCP ports on all the firewalls -- but in using the wrong address for replying.
Computer 1: Public IP = 100.5.195.74 (router), Private IP = 192.168.1.183 (Windows 10, NAT)
Computer 2: Public IP = 54.175.128.251, Private IP = 172.30.0.213 (AWS)
On Computer 1, I call TetheringManager.DiscoverManagers using Computer 2's Public IP address as the target. Using TTetheringLogItem on Computer 2, I log the messages in and out -- the 6 messages logged are shown below. The first 3 messages correctly note Computer 1's public IP address as the source of the data packet, although the content of the message (composed by Computer 1) includes Computer 1's local IP address. In the last 3 messages, including when Computer 2 is trying to reply to Computer 1, it has dropped Computer 1's public IP address and is only using its private IP address. Computer 1 never receives the message because it wasn’t sent to its public IP address.
Is there a way to tell the tethering manager to reply using the public IP address the messages came from? Better still, it could automatically try the public IP if the private IP failed.
2020/02/29 21:17:12: Log: DoOnReceiveData("100.5.195.74$2020") Data: "TetheringDiscoverManagers|192.168.1.183$2020|1|2020~"
2020/02/29 21:17:12: Log: DoOnReceiveData - Enqueue Command: "100.5.195.74$2020|TetheringDiscoverManagers\|192.168.1.183$2020\|1\|2020"
2020/02/29 21:17:12: Log: Net-In(100.5.195.74$2020): MyManager: Waiting -> TetheringDiscoverManagers|192.168.1.183$2020|1|2020
2020/02/29 21:17:12: Log: In(192.168.1.183$2020): 0: MyManager: Waiting -> TetheringDiscoverManagers|192.168.1.183$2020|1|2020
2020/02/29 21:17:12: Log: Out(192.168.1.183$2020): state: Waiting; Resp: <TetheringServerDiscovered|172.30.0.213$2020|1|{9816D745-81C2-4CD9-9F10-92DEB4FF7694}|TetheringManager|MyManager|Network~>
2020/02/29 21:17:12: Log: Net-Out(192.168.1.183$2020): state: Waiting; Resp: TetheringServerDiscovered|172.30.0.213$2020|1|{9816D745-81C2-4CD9-9F10-92DEB4FF7694}|TetheringManager|MyManager|Network~