SOAP Error: Could not connect to host

Discussion in 'Installation/Configuration' started by minddigger, Feb 20, 2013.

  1. minddigger

    minddigger New Member

    Hi, I want to use the API of ISPConfig 3.0.4.6 and therefore I have made a test script (using example), simply to connect to the SOAP server.
    It runs on a Ubuntu 12.04.2 LTS precise server.
    I have to mention that I had for about 4 months ago a working script, but now, after I have upgraded the server, it no longer works.

    The script is very common:

    $username = 'remoteusr';
    $password = 'password';


    $soap_location = 'https://myserverip:8080/remote/index.php';
    $soap_uri = 'https://myserverip:8080/remote/';


    $client = new SoapClient(null, array('location' => $soap_location,
    'uri' => $soap_uri,
    'trace' => 1));

    // ini_set('soap.wsdl_cache_enabled',0);
    // ini_set('soap.wsdl_cache_ttl',0);

    try {
    //* Login to the remote server
    if($session_id = $client->login(trim($username),trim($password))) {
    echo 'Logged into remote server sucessfully. The SessionID is '.$session_id.' - <br>';
    }

    //* Logout
    if($client->logout($session_id)) {
    echo "Logout for session ".$session_id;
    }

    } catch (SoapFault $e) {
    var_dump($client->__getLastRequest())."<br>";
    var_dump($client->__getLastResponse())."<br>";

    echo "<br>Please contact the server administator<br>";
    die('SOAP Error: '.$e->getMessage());
    }


    The getLastRequest gives me the username and password back
    The getLastResponse gives me NULL

    I don't get what is wrong here, especially where it did work before!!
     
  2. till

    till Super Moderator Staff Member ISPConfig Developer

    The error "SOAP Error: Could not connect to host" indicates that either $soap_location or $soap_uri are incorrect so that sopa could not reach a server under that url.
     
  3. minddigger

    minddigger New Member

    Yes that could be possible, but... The $soap_location AND the $soap_uri are right. They are besides the /remote part the same as what I use to login to my ISPConfig. Offcourse the 'myserverip' should be replaced by the IP or URL of the real server, but I will not encourage anyone to hack my server at this moment ;-)

    When I enter the whole URL in a browser, I get a blank screen as well. I think at least it should display something...
     
  4. till

    till Super Moderator Staff Member ISPConfig Developer

    No, it has to be blank. When you connect to a soap server with a web borwser, then nothing gets displayed.

    Did you run the browser on the same server that you run the php script on, so the connection is made from same network interface and IP?
     
  5. minddigger

    minddigger New Member

    Yes, I developped it on my Desktop PC and call the servers SOAP from there. It did work in the past as I did mention earlyer and I was able to add a user as well in the API, but now it does not work anymore. As far as I can see nothing has changed, besides the upgrade of the (Ubuntu) server OS.
     
  6. till

    till Super Moderator Staff Member ISPConfig Developer

    maybe the php soap extension is not installed of the server anymore. You can e.g. check that with the phpinfo() function if soap is available.
     
  7. minddigger

    minddigger New Member

    Nope, this have I already checked. SOAP is available.
     
  8. minddigger

    minddigger New Member

    It even getting stranger: When I use the script on a different server, or from my home location, where 'myserverip' is my server IP address or my server URL like this :

    $soap_location = 'https://myserverip:8080/remote/index.php';
    $soap_uri = 'https://myserverip:8080/remote/';

    I got a SOAP Fault.

    When I run the same script on the SOAP server itself using
    $soap_location = 'https://localhost:8080/remote/index.php';
    $soap_uri = 'https://localhost:8080/remote/';

    it works fine!!!

    When I call the SOAP servers ISPConfig admin screen from a different server, using
    'https://myserverip:8080' or 'https://myserverURL:8080' I got the login screen of ISPConfig, so it could not be a DNS problem.
    I'm confused because I have tried it on different servers with ISPConfig and everywhere got the same result....
     
    Last edited: Feb 22, 2013
  9. ismo-conguairta

    ismo-conguairta New Member

    What is your PHP version?

    This should be related to php-5.6. All encrypted client streams now enable peer verification by default. If you use a self-signed certificate, the peer verification fails. In my ispconfig installation on Debian Jessie I solved with the following steps.

    Copy the ISPconfig CA (=CRT for self-signed) to dir /usr/local/share/ca-certificates/

    # cp /usr/local/ispconfig/interface/ssl/ispserver.crt /usr/local/share/ca-certificates/
    # update-ca-certificates

    Then change the related php.ini file. If you use fcgi for roundcube you have to modify /etc/php5/cgi/php.ini and add in section [openssl] the following line:

    openssl.cafile=/etc/ssl/certs/ca-certificates.crt

    Then, restart apache

    # service apache2 restart
     
    MasteRTriX and till like this.
  10. renky

    renky New Member

    Or simply deactivate peer-check in your php-script:

    $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)))
    ));

    this worked for me
     
  11. wetzesas

    wetzesas New Member

    This is working fine for me too.
     
  12. sjau

    sjau Local Meanie Moderator

    Just encountered the same issue. Thx for the solution.
     
  13. gzx21

    gzx21 New Member

    Hi,
    I seem to have the same problem. I am using Debian Jessie, ISPC 3.0.5.4p8, Apache, PHP 5.6 and Roundcube 0.9.5. Everything (besides Debian itself) is installed according to the guides on howtoforge. I think that with update to Jessie and subsequent update to PHP 5.6, this feature stopped working.
    We have a Class 2 certificate from StartCom for our server, so there shouldn't be a problem with an invalid certificate. I also checked that SOAP extension is enabled for PHP.

    The /usr/share/roundcube/plugins/ispconfig3_account/config/config.inc.php reads:
    Code:
    $rcmail_config['identity_limit'] = false;
    $rcmail_config['remote_soap_user'] = 'roundcube';
    $rcmail_config['remote_soap_pass'] = 'somepassword';
    $rcmail_config['soap_url'] = 'https://our.server.com:8080/remote/';

    Any other ideas what to check? The error is the same: "Soap error: could not connect to host".

    Thanks!
     
    Nemis likes this.
  14. todx

    todx Member

    Works, thank you.
     
  15. Bane

    Bane New Member

    [QUOTE="'stream_context'=>stream_context_create(array('ssl'=>array('verify_peer'=>false,'verify_peer_name'=>false)))[/QUOTE]
    where in roundcube is that file ? to put these in and is it possible to protect ip:host/remote with fail2ban ignore ip would be localhost of course and findtime 1 and max retry 1 and time for ban -1 ... :) thank you
     
  16. luigi mangili

    luigi mangili New Member

    this happen to me whwn i try to use the import ispconfig function...


    Import email configuration from ISPConfig 3
    Remote server connection details
    Remote API URL ...pippo.it:8080/remote/
    Remote User pippo
    Remote password passippo

    1. Could not connect to host
     
  17. vikozo

    vikozo New Member

    where is this file to Change it?
     
  18. till

    till Super Moderator Staff Member ISPConfig Developer

    That's in your own script that you use to connect to ISPConfig.
     
  19. vikozo

    vikozo New Member

    Hello Till
    found the file /opt/roundcube/plugins/ispconfig3_account/ispconfig3_account.php
    another question because somewhere you said it should not be changed
    in the file
    /opt/roundcube/plugins/ispconfig3_account/config# config.inc.php
    $rcmail_config['soap_url'] = 'https://server1.example.com:8080/remote/';
    if i use my privat IP Address ist thei a Problem?
    $rcmail_config['soap_url'] = 'https://10.147.10.68:8080/remote/';

    ---
    this Soap error in which log file are they saved, maybe i would finde more Information about the Problem?
     
    Last edited: Jan 25, 2018
  20. vikozo

    vikozo New Member

    any Idea where SOAP error are logged - i would hope to get some Information whats wrong?!
     

Share This Page