The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Urgent : Not able to make connection with client

Discussion in 'cPanel Developers' started by moneesh.koundal, Oct 1, 2008.

  1. moneesh.koundal

    moneesh.koundal Registered

    Joined:
    Oct 1, 2008
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    1
    Not able to make connection with client

    I am trying to use WHM XML api when i try to connect to the WHM server using php script I got this error

    Warning: fsockopen() [function.fsockopen]: unable to connect to ssl://dob.mochahost.com:2087 (A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. )

    php script :
    <?phpclass Whm
    {
    var $controller = true;
    var $protocol = null;
    var $host = null;
    var $user=null;
    var $accessHash = null;
    var $errors=array();
    var $fp=null;

    /*
    * initialization
    */
    function startup(&$controller)
    {
    $this->controller =& $controller;
    }

    /*
    * initialization
    */
    function init($protocol,$host,$user,$accessHash)
    {
    $this->protocol=$protocol;
    $this->host=$host;
    $this->user=$user;
    $accessHash = str_replace(array("\r", "\n"),"",$accessHash);
    $this->accessHash=$accessHash;
    }
    function connect($api_path)
    {
    if ($this->protocol == 'http') {
    /*
    * Uncomment to use unsecure HTTP instead
    */
    $this->fp = fsockopen($this->host, 2083, $errno, $errstr, 30);
    } else if ($this->protocol == 'https') {
    /*
    * Open a socket for HTTPS
    */
    $this->fp = fsockopen("ssl://" . $this->host, 2087, $errno, $errstr, 30);
    }

    /*
    * Die on error initializing socket
    */
    if ($errno == 0 && $this->fp == false)
    {
    $this->errors[]="Socket Error: Could not initialize socket.";
    return false;
    }
    elseif ($this->fp == false)
    {
    $this->errors[]="Socket Error #" . $errno . ": " . $errstr;
    return false;
    }

    function version()
    {
    //connect using prpoer xml api address
    $this->connect('/xml-api/version');
    //get the output
    $xmlstr=$this->getOutput();
    if($xmlstr=='')
    {
    $this->errors[]='No output.';
    return false;
    }
    //disconnect
    $this->disconnect();

    $xml = new IsterXmlSimpleXMLImpl;
    $xmldoc = $xml->load_string($xmlstr);

    return $xmldoc->version->version->CDATA();
    }
    }

    $test->init('https','dob.mochahost.com','username','accesskey');
    //This will output the cpanel/whm version.
    echo "after init call";

    $version= $test->version();
    echo "Hostname: $version <br>";
    ?>

    I want to make connection with my clients whm site but it gives warning in that and no connections open if any one can help me in that as it is urgent.
     
    #1 moneesh.koundal, Oct 1, 2008
    Last edited by a moderator: Oct 1, 2008
  2. cPanelDavidG

    cPanelDavidG Technical Product Specialist

    Joined:
    Nov 29, 2006
    Messages:
    11,279
    Likes Received:
    8
    Trophy Points:
    38
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    By glancing over your code, I don't find any glaring errors. Does this also happen if you attempt a connection over plain text (HTTP)? I ask because it does seem to be a connection issue based off the information provided thus far... perhaps a firewall issue.
     
Loading...

Share This Page