Remote API problem

Discussion in 'Developers' Forum' started by Xicer, Jan 15, 2015.

  1. Xicer

    Xicer New Member

    Hello there,
    I'm using the ISPConfig Remote API for various tasks. Everything worked fine but then suddenly I started getting errors with the API.
    Sometimes when I call the following code:
    PHP:
    try {
                
    //connect to ISP
                
    $options App::getOptions()->toArray();
                
    $client = new SoapClient(null, array('location' => $options['isp_config']['info']['soap_location'],
                                                     
    'uri'      => $options['isp_config']['info']['soap_uri'],
                                                     
    'trace' => 1,
                                                     
    'exceptions' => 1));
                
    //get database name for the db_user
                
    if($session_id $client->login($options['isp_config']['info']['username'], $options['isp_config']['info']['password'])) {
                    
    //some tasks
                
    }
                
    $client->logout($session_id);
    } catch(
    Exception $e){
                    
    App::wdLog(print_r($e->getMessage(), 1), 'errors');
                    exit;
    }
    I get an exception "The login failed. Username or password wrong." After I refresh the page a few times, sometimes even 1 refresh is enough then everything works fine.

    So my questions is. Why does it fail first and then works later on?
     
  2. till

    till Super Moderator Staff Member ISPConfig Developer

    Ay errors in the apache logs? Or maybe mysql restarts?
     
  3. Xicer

    Xicer New Member

    Can't find any errors in the apache logs. But I'm not sure about Mysql restarts. Is there a way to check that? Also the App::getOptions()->toArray(); is getting the options from a .ini file.
     
  4. till

    till Super Moderator Staff Member ISPConfig Developer

    The options from ispconfig are stored in nini file format i the database.

    Regarding mysql restarts, check the /var/log/syslog file.
     
  5. Xicer

    Xicer New Member

    Checked the logs, no Mysql restarts. Just had the same error a minute ago, no logs can be found except the "The login failed. Username or password wrong." in my log file. And again everything worked after a page refresh. Is there anything else I can check before we loose all hope? :/
     
  6. till

    till Super Moderator Staff Member ISPConfig Developer

    I never experienced such problems on a system yet, so it must be definately solvable. maybe a connection limit from mysql is reached. try to set max_connections and max_user_connections in [mysqld] section of the mysql my.cnf file to a higher value, e.g. 500.
     
  7. Xicer

    Xicer New Member

    So far it looks like that fixed the problem. Thank you. I'll have to rewrite some code, can't really leave it on 500 :)
     

Share This Page