Something wrong with API

ShinJii

Verified User
Joined
Mar 20, 2014
Messages
224
I don't know when it happened but I guess something around year ago after changing server from centos 7 to alma linux 8... I have something like that in my script PHP (I'm using that to connect with API https://files.directadmin.com/services/all/httpsocket/httpsocket.php )


PHP:
$da = new HTTPSocket;
  /* ADD DOMAIN */
  $da->connect($server, $server_port);
    $da->set_login($da_login, $da_pass);

 $da->set_method('post');
                $da->query('/CMD_API_DOMAIN', array('action' => 'create', 'domain' => $domain, 'ubandwidth' => 'unlimited', 'uquota' => 'unlimited', 'ssl' => 'ON', 'cgi' => 'ON', 'php' => 'ON'));
   $result = $da->fetch_body();


/* ADD SSL CERTIFICATE */
   $da->set_method('post');
                    $da->query('/CMD_API_SSL', array('action' => 'save', 'domain' => $domain, 'type' => 'create', 'request' => 'letsencrypt', 'name' => 'www.' . $domain, 'email' => '[email protected]', 'keysize' => '4096', 'encryption' => 'sha256', 'le_select0' => $domain, 'le_select1' => 'www.' . $domain, 'submit' => 'save'));
                    $result = $da->fetch_body();
And I don't know why but after instructions in /* ADD DOMAIN */ there's an error in browser like "Lost connection, try again" - after click "Try again" it asks if I want to send Form (POST) again, I click yes... and it shows that DOMAIN EXISTS (so it looks like it created domain even if browser showed error) and just creating let's encrypt.
I don't know why it's going like that? Can you look at it @smtalk ? :)
I noticed that if I restart Directadmin (service) it works normally without that error in browser... after few minutes (or hours?) there's again always error...
 
If you run the script on the same server where you connect to DirectAdmin to, then a webserver reload/restart is expected.
 
If you run the script on the same server where you connect to DirectAdmin to, then a webserver reload/restart is expected.
I don't think so, without reload/restart it's working but only after second refresh in browser ;p
And my mistake - that error in browser isn't "lost connection" but "no SSL connection" even if I have SSL - after refresh page with confirmation to send form again it's working xD
 
You don't think what? That a webserver reload/restarted takes place after a domain is added? You might check your web-server logs and see it there. Otherwise a newly added domain won't show up in HTTP/HTTPS.

If you mean that the webserver restart/reload is not the reason of the following errors "lost connection" but "no SSL connection", then you might have right. The provided information does not have much clues to make other guesses.
 
You don't think what? That a webserver reload/restarted takes place after a domain is added? You might check your web-server logs and see it there. Otherwise a newly added domain won't show up in HTTP/HTTPS.

If you mean that the webserver restart/reload is not the reason of the following errors "lost connection" but "no SSL connection", then you might have right. The provided information does not have much clues to make other guesses.
I thought you said that I HAVE TO reload/restart webserver after operation, if it's doing it automatically - I don't care :D but I think it's not the reason of "no ssl connection", like I said - it was working on CentOS 7 without any problems :P it happened after changing system to Alma 8:D
 
The most obvious changes happened with a migration from CentOS 7 to AlmaLinux 8 are:

- openssl version
- curl version

Probably something from these effects your script. Not too sure. Need more information.
 
The most obvious changes happened with a migration from CentOS 7 to AlmaLinux 8 are:

- openssl version
- curl version

Probably something from these effects your script. Not too sure. Need more information.
Yeah But it's weird it's working after refresh page, isn't it? :D
 
I did not see the issue with my own eyes, so I would rather not evaluate it.

Another guess of mine is here, you might have wrong configured linked IPs. As an example your domain resolves to IPv6 or several IPv4, but not all of them are linked in a webserver. And some requests go wrong.

p.s. Just shooting in a dark. No much helpful. More details on the issue are required.
 
Back
Top