A method for puncturing one or more Network Address Translation (NAT) services that are located between a first electronic device and a second electronic device,
- wherein the first electronic device runs a first application that is configured to send a first set of Internet Protocol (IP) packets to a second application running on a second electronic device and to receive a second set of IP packets from said second application,
- wherein the second electronic device runs the second application that is configured to receive the first set of IP packets from the first application and to send the second set of IP packets to the first application,
- wherein the second set of IP packets is routed, from the second electronic device to the first electronic device, via a first Network Address Translation (NAT) service,
- wherein at least one of the first application and the second application requires puncturing of said first NAT service in order to establish or maintain communication with the other of the first application and the second application, and
- wherein a Message Broker is accessible via the public Internet to both the first electronic device and the second electronic device,
- the method comprising:
- at the first electronic device, executing Session Traversal Utilities for NAT (STUN) protocol to obtain a first pair of external IP address and port of the first electronic device;
- at the second electronic device, executing the STUN protocol to obtain a second pair of external IP address and port of the second electronic device;
- at the first electronic device, sending a first informing message to said Message Broker, wherein the first informing message indicates the first pair of external IP address and port of the first electronic device;
- providing, by the Message Broker, the first informing message to the second electronic device;
- at the second electronic device, sending a second informing message to said Message Broker, wherein the second informing message indicates the second pair of external IP address and port of the second electronic device;
- providing, by the Message Broker, the second informing message to the first electronic device;
- at the first electronic device, utilizing a Virtual Private Network (VPN) function to communicate with the second electronic device by sending, via a first VPN server, packets for NAT puncturing addressed to the second pair of external IP address and port of the second electronic device that were indicated to the first electronic device by the second informing message via the Message Broker;
- at the second electronic device, communicating with the first electronic device by sending packets for NAT puncturing addressed to the first pair of external IP address and port of the first electronic device that were indicated to the second electronic device by the first informing message via the Message Broker;
- at the second electronic device, after communications using addresses and ports received from the Message Broker, sending a subset of said second set of IP packets of said second application to said first application by setting their destination IP address to one of:
- (a) the external IP address of said first electronic device as received from said Message Broker, or (b) a source IP address as obtained from incoming puncturing packets that were received at the second electronic device from said first electronic device, or (c) a source IP address as obtained from packets of said first application that were received at the second electronic device from the first electronic device;
- at the first electronic device, sending a subset of said first set of IP packets to said second application running on said second electronic device by setting their destination IP address to a source IP address as obtained from the subset of said second set of IP packets that were received at the first electronic device from said second application of the second electronic device.