OK, let's condense this a bit.
1) I found this thread:
https://forum.lazarus.freepascal.org/index.php/topic,38318.0.htmlsame author as this thread. I was actually thinking about "keep alives"
2) Change of IP on the client: --> Is this Client and the PG-Server on the same LAN, or is it the "Client reaches over the Internet to the Server" --> a.k.a is the Client in LA, and connects to the Server in NYC via Internet?
because if
both are on the same LAN, you have max 254 "free" IP's on the smallest "private" Subnet (192.168.0.xxx).
Solution: since the server already has a static IP, assign static IP's to the client(s) and be done with it.
If it must be DHCP, your only chance IMO is to "compare" current IP to "saved" IP.
e.g. on startup you save the current IP to a variable (or wherever else). You connect, you do work, life is good.
Now your client sits idle for how many long hours, running into an IP-Change because of expiry of Lease?!??!
Before any action is taken (any CRUD-Statement), compare the then current IP to this saved IP.
If same, go on, if not, drop/close connection, and reconnect with that new IP, save that IP to that Variable.
3) IIRC, there was not long ago a thread discussing "best practice": connect at App-Startup, close on App-Shutdown versus before "CRUD-Action" connect, after "CRUD-Action" close connection