DDNS resolution from PHP is erratic

Hello,
For the past few days, DDNS name resolution from PHP hasn’t been completed in a reasonable amount of time, and when it does, the name cache doesn’t last even a minute. It’s not a DDNS propagation issue, because we’re talking about a DDNS that had already been resolved minutes earlier from the same host. I’d like to know if any of you have experienced the same problem or if it’s a known issue and if there’s a solution.
Thank you.

Please provide your domain name.

2 Likes

I’m very confused. DDNS and PHP are two entirely separate things functioning nowhere near the same way and having two completely separate purposes.

DDNS is a thing, but not in the way you described it, I think you mean DNS propagation.

From the information you shared, I think DNS propagation is what you are waiting for, see the article below for more information:

7 Likes

@jaikrishna.t
My domain is: manelestrada.rf.gd
@Greenreader9
Sorry, maybe I didn’t explain myself enough, read the “Scenario” section of this post.

It seems I’ve found the solution, but this isn’t normal.

Until a few days ago, DDNS was resolved without problems directly in the connection command itself with:
$conn_id=ftp_connect($ftp_server);

Now I must first do:
$resolved_ip = gethostbyname($ftp_server);

And then:
$conn_id=ftp_connect($resolved_ip);

It seems that the timeout is now shorter in ftp_connect() than in gethostbyname(), possibly due to a poorly calibrated asynchronous resolution in the PHP operating environment.

Scenario:
I connect to a DDNS that points to the IP of the WAN connection on my local network, where I host an FTP server (since I couldn’t get it to connect to an SFTP server from this host at the time…) to download data on demand from my InfinityFree website using my local FTP server.

Greetings, and I hope the DDNS resolution directly from ftp_connect() is revised to use the same timeout as gethostbyname().

Thanks!

1 Like

Thank you for clarifying.

As I understand it, you’re having intermittent issues setting up an FTP connection from the PHP code hosted with us, to your FTP server which is running at your home. The PHP code that’s supposed to make the FTP connection should be able to find your home IP through a Dynamic DNS hostname.


For starters, it doesn’t really matter from our end whether you are using a Dynamic DNS endpoint or not. From our side, or anything else that needs to find your home IP, it’s just a hostname that can be resolved by DNS.


Secondly, are you sure that the issue you’re having is a DNS issue? Did you try enabling display_errors on your website and see what error message is returned by the connection? Can you share the error message you received?


First doing gethostbyname before ftp_connect helping makes no sense to me. Under the hood, they all use the same system calls which will ultimately just use the system’s DNS settings to resolve the domain.


It would help a lot for troubleshooting if you could share the DNS name that the server is having trouble resolving. If you don’t want to share that, then can you at least tell us which Dynamic DNS service you are using so we can try to reproduce the issue?

And for good measure, how dynamic is your IP address? How frequently does it change?

4 Likes

Hello,

I realized that the problem was caused by a poor DDNS resolution by connecting to my local FTP service directly from InfinityFree with my real IP, so I didn’t need to enable display_errors, but I couldn’t because you have display_errors=Off in php.ini and I, at least with a free account, couldn’t activate it.

My DDNS service is dnsexit.com. In my case, the IP changes frequently at least once a day. If you need my DDNS name, let me know, and I can provide it in a private message.

If you’d like more details, let me know.

Thanks!

From your account dashboard click on cpanel then in the software section click on alter php config

From there you can click alter php config and then enable display errors

5 Likes

Thanks, I hadn’t seen it and I’ve already checked that the error reporting works, but the environment where I have the connection to my FTP is SVG and I’m having trouble getting it to show the errors, if there are any, since I get the impression that when the connection fails, which isn’t always, it does so silently.

1 Like

I’m sorry, but I don’t agree with “it worked from my machine but not from your servers, so it’s your DNS resolver”. I think it’s premature to conclude that it is DNS related at all.

Please try to get more information about what is actually going wrong. I have no desire to go on a wild goose chase for an issue that may not exist at all, because of something you assume is a problem with basically no evidence to support it other than “it works on my machine”.

When ftp_connect fails, it will send an error message through the standard PHP logging facility. By default, nothing will happen with the error, but if you enable display_errors through our panel, the errors will be shown on your website.

This behavior can be changed completely through your website. Through methods like init_set(), error_reporting() and set_error_handler(), you can change when, how and where errors will be handled.

So if you enabled display_errors and are not seeing any messages, please try searching you codebase for the functions I referenced above to see if that may be causing the error message to appear.

To be clear: ftp_connect always returns an error, but it’s up to your application what happens with that error.

4 Likes

I understand your position, especially since no one else has complained about the problem. For now, all I know is that using gethostbyname() previously not problem, and I’ve incorporated error handling into my script in PHP to notify me if the problem occurs with gethostbyname() showing the IP it receives

Directly with ftp_connect(), which is when I have the problem, I’ll try to create a script that notifies me, although using ftp_connect() directly isn’t as easy to tell me the root of the problem. I’ll figure something out.

And it will try to cause the error outside of the SVG environment since system errors are not displayed in that environment.

I’ll keep you informed of anything I find out.

Thanks.

I want to state again: ftp_connect() always sends an error message to the PHP error handler if the connection failed. If you’re not seeing an error message, it could mean:

  • The display_errors option is not enabled.
  • The error message is shown, but not visible due to where it is printed on the page. Sometimes using the View Source option can help.
  • Something in your website code is overriding how errors are handled, which is handling the error differently or simply hiding or discarding it.

Without the error message from ftp_connect(), we’re just making blind guesses as to what the issue could be.

5 Likes