[SOLVED] Can not access using Proxmox PHP API

kotakomputer

Renowned Member
May 14, 2012
429
13
83
Jakarta, Indonesia
www.proxmoxindo.com
This script below works fine on several server but only server from Hetzner doesn't.

<?php
require_once("pve2_api.class.php");

$pve2 = new PVE2_API("my-server-ip", "root", "pam", "my-password");

if ($pve2->login()) {
foreach ($pve2->get_node_list() as $node_name) {
print_r($pve2->get("/nodes/".$node_name."/status"));
}
} else {
print("Login to Proxmox Host failed.\n");
exit;
}
?>
To show detail error, I have added a break-point to determine the error point at pve2_api.class.php:

// Perform login request.
$prox_ch = curl_init();
curl_setopt($prox_ch, CURLOPT_URL, "https://{$this->hostname}:{$this->port}/api2/json/access/ticket");
curl_setopt($prox_ch, CURLOPT_POST, true);
curl_setopt($prox_ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($prox_ch, CURLOPT_POSTFIELDS, $login_postfields_string);
curl_setopt($prox_ch, CURLOPT_SSL_VERIFYPEER, $this->verify_ssl);


$login_ticket = curl_exec($prox_ch);
$login_request_info = curl_getinfo($prox_ch);

if (!$login_ticket) {
// SSL negotiation failed or connection timed out
$this->login_ticket_timestamp = null;
print '<pre>';
print_r($login_request_info);
print '</pre>';
print " SSL negotiation failed or connection timed out";
return false;
}

The above script will return "SSL negotiation failed or connection timed out" because the $login_ticket failed.

It's works when using https://my-server-ip:8006 to make sure the username and password is right.
Any suggestions how to fix this issue?
 
This script below works fine on several server but only server from Hetzner doesn't.

So it seems the problem is going out from Hetzner, not the PHP API wrapper or PVE?

Did you asked them if they have anything configured to block such login/access attempts?
 
So it seems the problem is going out from Hetzner, not the PHP API wrapper or PVE?

Did you asked them if they have anything configured to block such login/access attempts?
Right, above code running well on other Data Centers, I have use it for hundreds servers.
Unfortunately, Hetzner does not help, I have open Ticket to Hezner but they told me to ask to forum.
 
i'd check wether a standard "Hetzner server" has the same ports listening on, then your "hundreds of working servers". Then verify that all those ports on your hetzner Server can actually be reached from the outside world.

That would tell you if hetzner does anything to block your requests.
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!