There are two Internet providers. which "fall off" with unpredictable periodicity. Accordingly, the server has two IP (from two Internet providers), between which you have to switch to maintain the site (data is being uploaded from the server).
The task is to check which connection is active. It is desirable to quickly ... What I tried: I created a file on the server and check what query (through what IP) it is available. But...
is_readable, file_exists - false with active connection
fopen, file_get_contents - correspond to the situation, but they are “spinning” for quite a long time.
get_headers - sometimes does not work (does not give headers, although the file is opened or given)
Questions: What is the best way to check connection activity? Is the logical way I chose? Maybe the idea to read the file is not the best, but it is worth trying to connect to the database?