@AndrewGifft’s point about the potential problem of using an ip address to contact a server and latter losing that static ip address may seem unlikely, but it actually did happen to me. The whole system was an IoT one and all devices were deployed and mobile. It was a nightmare.
The data packets I was sending were only 17 bytes long, and I couldn’t bear to add so much DNS lookup data, so I created and deployed a solution like this:
- I use a fixed ip address to contact the application server, same as I was doing.
- I also put up a second, very simple server which I call a “server-server.” This server can be accessed by a URL. When contacted, all it does is respond with the ip address of the application server.
The application attempts to contact the application server using the fixed ip address. If it discovers the host is unreachable, or the server isn’t responding appropriately (maybe the ip address was lost by the application server and is now being used by an entirely different server) it contacts the server-server to get the proper ip address of the application server.
If, for whatever reason, the ip address of the application server must be changed, the server-server is tweaked to provide the new ip address of the application server.
The overwhelming majority of the time the application will connect to the application server correctly using the fixed ip address. Only rarely will the application every need to contact the server-server and use the additional bytes necessary for DNS lookup.
I’ll also mention the the server-server can be implemented as just a few lines of php code. just a few lines of php