I am using miniupnp to add a port mapping to a router, the port is mapped for a “lease” amount of time, I am using a random 10 hours at the moment, my question is:
after the port is successfully mapped should I ping the router periodically to check if the port is still mapped (for example every minute or even less) or do I trust the router to keep the port mapped for the whole duration of the lease, and only check few minutes before the lease expires to renew it ?
Similarly after a successful port mapping another call is made to retrieve the external IP address, do I trust that this IP will not change or should I keep pinging every few seconds (or minutes?) to verify that the external IP address has not changed ?
You can subscribe to UPnP event of WAN***Connection (PPP or IP) and catch the event “PortMappingNumberOfEntries”.
I hope this helps.