I'm trying to create a program that incorporates a kind of exchange JSONs messaging system where there is an A or central device, of which we know its static IP and one or more B devices, which have a dynamic and unstable IP.
The communication I propose should be viable not only from B to A (including answer or not from B) but also from A to B, with the same results.
My messaging skills are limited to ZMQ, so I had thought about two possible situations:
On the first one, based on PUSH-PULL sockets, A has a PULL socket and another PUSH socket, in the same way as B. As a heartbeat, B sends a JSON every X seconds/minutes saying "This is my IP". That information is considered reliable within a time range and, on the one hand, we solve the communication from B to A (fairly easy) and on the other hand B has saved an IP with which to try to contact with a minimum of reliability.
ON the second one, I thought about on REQ-REP sockets. In this configuration, A has a RES socket, capable of receiving and responding requests from B, which in turn has an associated REQ socket for performing the requests. The communication from B to A, again, is simple. Conversely, the idea would be to have B throwing REQ requests as a heartbeat (every half second, for example), asking "Is there something for me? Is there something for me?" Much more reliable than the first but much less efficient at the network level (I completely ignore the real cost of this type of calls).
Is there a better proposal to start with? I want to emphasize that I use ZMQ because it is what I know, but if there are much better tools / more adapted to this type of situation, I will be happy to know and / or work with them. I know Google has a kind of API for Android but I'm not talking specifically about smartphones.
Remember that the end that PUSHes or REQuests or whatever is totally independent of the end that binds or connects. So the device that has the stable IP address can bind its zmq sockets and everything else connects their zmq sockets to that IP address, but you can then choose which end is PUSH or PULL, or REQ or REP
Best way of communicating two devices knowing only one IP