After upgrade to ISPC 3.1, SOAP login gives 500 Internal Server Error

Discussion in 'General' started by Reinhold Kainhofer, Nov 20, 2016.

  1. Reinhold Kainhofer

    Reinhold Kainhofer New Member

    I have a small script that basically implements DDNS for two hosts by using SOAP calls to change the A record of a given subdomain. Now, after the upgrade from 3.0.5pX to 3.1.1p1 (and Ubuntu 14.04 to 16.10), the soap call (the very first login call) gives an Internal Server Error:
    Code:
    root@DiskStation:~# /volume1/\@appstore/PHP5.6/usr/local/bin/php56 /volume1/temp/ispconfig-ddns/update.php aon kainhofer.com 
    PHP Fatal error:  Uncaught SoapFault exception: [HTTP] Internal Server Error in /volume1/temp/ispconfig-ddns/update.php:36  
    Stack trace:  
    #0 [internal function]: SoapClient->__doRequest('<?xml version="...', 'https://server....', 'https://server....', 1, 0)  
    #1 /volume1/temp/ispconfig-ddns/update.php(36): SoapClient->__call('login', Array)  
    #2 /volume1/temp/ispconfig-ddns/update.php(36): SoapClient->login('REMOTEUSER', 'PASSWORD')  
    #3 {main}  
     thrown in /volume1/temp/ispconfig-ddns/update.php on line 36                                                                                                             

    On the server, I cannot see any log entry about the server error, except the /var/log/ispconfig/httpd/server.kainhofer.com/access.log:
    Code:
    80.123.61.86 - - [20/Nov/2016:14:19:25 +0100] "POST /remote/index.php HTTP/1.1" 500 4059 "-" "PHP-SOAP/5.6.23" 
    80.123.61.86 - - [20/Nov/2016:14:21:37 +0100] "POST /remote/index.php HTTP/1.1" 500 4059 "-" "PHP-SOAP/5.6.23"
    However, I don't see any indication what exactly went wrong. Here is my whole DDNS script:
    Code:
    <?php
    #require('config.php');
    $soap_location= 'https://server.kainhofer.com:8080/remote/index.php'; 
    $soap_uri= 'https://server.kainhofer.com:8080/remote/'; 
    $soap_user= 'REMOTEUSER'; 
    $soap_password= 'PASSWORD'; 
    
    if($argc<3){
        print "Usage: php ./update.php HOST DOMAIN [IP]\n"; 
        print "If not given, the ip address will be queried from icanhazip.com\n"; 
        die(); 
    }
    
    $ddns_host=$argv[1]; 
    $domain=$argv[2]; 
    if($argc>3){
        $ip=$argv[3]; 
    }else{
        $ip=trim(file_get_contents("http://icanhazip.com/")); 
        if(filter_var($ip, FILTER_VALIDATE_IP)===false){
            die("Unable to retrieve public IP address (icanhazip.com returned $ip)\n"); 
        }
    }
    
    $client=new SoapClient(null, 
        array('location'  =>$soap_location, 
         'uri'  =>$soap_uri, 
         'trace'  =>1, 
         'stream_context'=>stream_context_create(array('ssl'=>array('verify_peer'=>false,'verify_peer_name'=>false))), 
         'exceptions' =>1)); 
    
    //try {
        $session_id=$client->login($soap_user, $soap_password); 
    
        $zone_id=$client->dns_zone_get_id($session_id, $domain); 
        $zone=$client->dns_zone_get($session_id, $zone_id); 
        $records=$client->dns_rr_get_all_by_zone($session_id, $zone_id); 
    
        $dns_record=null; 
         foreach($recordsas$rec){
             if($rec['type']=='A' &&$rec['name']==$ddns_host){
                 $dns_record=$rec; 
             }
         }
         if(is_null($dns_record)){
             $client->logout($session_id); 
             die("Unable to find DNS record for host $ddns_host in domain $domain on the server...\n"); 
         }
        if($dns_record['data']!=$ip){
            $dns_record['data']=$ip; 
            $dns_record['serial']=$dns_record['serial']+1; 
            $client->dns_a_update($session_id, null, $dns_record['id'], $dns_record); 
    
            $zone['serial']=$zone['serial']+1; 
            $client->dns_zone_update($session_id, 0, $zone_id, $zone); 
    
    //        print("Successfully set DNS entry for host $ddns_host in domain $domain to $ip.\n");
        }else{
            print("IP address of $ddns_host.$domain already set to $ip.\n"); 
        }
    
        $client->logout($session_id); 
    
    //} catch (SoapFault $e) {
    //     die('SOAP Error: '.$e->getMessage()."\n");
    //}
    ?>
    
    Any idea what causes the Internal Server Error or where I might look for further information?

    Thanks,
    Reinhold
     

Share This Page