Community Forums
Connect with us on LinkedIn
Community Notice
+ Reply to Thread
Results 1 to 9 of 9
  1. #1
    Member
    Join Date
    Jun 2007
    Posts
    41

    Default Connection timed out when using xml-api

    Hello folks,

    I've been trying to use the xml-api functions for a couple of weeks now.

    It appears the fsockopen functions timed out randomly. Sometimes it works like a charm a dozen times and then suddenly it stops, and put a connection timed out error

    I tried loading the page on several computers, same issues. There's no firewall so this is not a port issue.

    I don't know how to trace a socket connection, otherwise I may look more precisely where the connection breaks. One thing I'm sure, there's nothing on the login logs so the connection stops before...

    Can someone help me figure this out ?
    thanks !

    dominique

  2. #2
    Technical Product Specialist cPanelDavidG's Avatar
    Join Date
    Nov 2006
    Location
    Houston, TX
    Posts
    10,720
    cPanel/Enkompass Access Level

    Root Administrator

    Default

    Is the script located on the same server as the WHM interface the API is attempting to interface with (localhost) or another server?

  3. #3
    Member
    Join Date
    Jun 2007
    Posts
    41

    Default

    It is located on another server,
    I did a netstat -an and it shows cpanel listening for all ips on port 2082 2083
    I still don't know where the issue is ...

  4. #4
    Technical Product Specialist cPanelDavidG's Avatar
    Join Date
    Nov 2006
    Location
    Houston, TX
    Posts
    10,720
    cPanel/Enkompass Access Level

    Root Administrator

    Default

    Quote Originally Posted by dom974 View Post
    It is located on another server,
    I did a netstat -an and it shows cpanel listening for all ips on port 2082 2083
    I still don't know where the issue is ...
    What about port 2086 (if using HTTP) or 2087 (if using HTTPS) which are used by the XML-API?

  5. #5
    Member
    Join Date
    Jun 2007
    Posts
    41

    Default

    Quote Originally Posted by cPanelDavidG View Post
    What about port 2086 (if using HTTP) or 2087 (if using HTTPS) which are used by the XML-API?
    Sorry I meant 2086 and 2087 of course ...
    I just updated php and apache to make sure this is not a LAMP issue but no ...

    Do you have an exemple of getting the xml stream by using something else than fsockopen() maybe ?

    Thanks

    Dominique

  6. #6
    Technical Product Specialist cPanelDavidG's Avatar
    Join Date
    Nov 2006
    Location
    Houston, TX
    Posts
    10,720
    cPanel/Enkompass Access Level

    Root Administrator

    Default

    Quote Originally Posted by dom974 View Post
    Sorry I meant 2086 and 2087 of course ...
    I just updated php and apache to make sure this is not a LAMP issue but no ...

    Do you have an exemple of getting the xml stream by using something else than fsockopen() maybe ?

    Thanks

    Dominique
    fsockopen() is the fastest method I am aware of to interface with the API with PHP. Using file_get_contents() will take more processor time, but you can find a very crude example with file_get_contents() instead of fsockopen() at:

    http://forums.cpanel.net/showpost.ph...0&postcount=14

  7. #7
    Member
    Join Date
    Jun 2007
    Posts
    41

    Default

    Doh, still the same "connection timed out" issue

    Is there any possibility to trace the socket opening and closing ?

    Dominique

  8. #8
    Technical Product Specialist cPanelDavidG's Avatar
    Join Date
    Nov 2006
    Location
    Houston, TX
    Posts
    10,720
    cPanel/Enkompass Access Level

    Root Administrator

    Default

    Quote Originally Posted by dom974 View Post
    Doh, still the same "connection timed out" issue

    Is there any possibility to trace the socket opening and closing ?

    Dominique
    According to http://us.php.net/fsockopen you can customize the timeout setting. Perhaps you may want to try that as a kludge to see if you can get the script working?

  9. #9
    Member
    Join Date
    Jun 2007
    Posts
    41

    Default

    Already tried timeout setting (increased) didn't do anything.

    BUT ... but ... I may have fixed it finally using Curl !

    My code (could be useful to someone else):
    $url = "http://$user:$pass@$theServer:2086$apiPath";
    $url=str_replace('&','&',$url);
    $ch=curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
    $result = curl_exec ($ch);
    curl_close ($ch);
    And then I do a stream to array conversion.

    It has been working quite well for the last 20 minutes, no error yet


    UPDATE : I talked too fast ... stille the same errors :'(

    UPDATE 2 : when I do a netstat -an I see that my connections stay in SYN_RECV state :
    tcp 0 0 91.121.73.71:2086 213.246.42.38:48272 SYN_RECV

    Anyone knows why my packet stops at this state ?


    Dominique
    Last edited by dom974; 08-23-2007 at 02:05 PM.

Similar Threads & Tags
Similar threads

  1. Connection timed out
    By czerdrill in forum cPanel and WHM Discussions
    Replies: 2
    Last Post: 03-02-2011, 01:43 PM
  2. The Connection has timed out
    By getnetphnx in forum cPanel and WHM Discussions
    Replies: 6
    Last Post: 02-25-2010, 04:10 PM
  3. xml-api connection
    By eugui in forum cPanel Developers
    Replies: 1
    Last Post: 02-20-2008, 01:00 PM
  4. FTP Connection Timed Out?
    By pagedeveloping in forum cPanel and WHM Discussions
    Replies: 1
    Last Post: 07-18-2007, 09:59 AM
  5. The connection has timed out
    By Celep in forum cPanel and WHM Discussions
    Replies: 0
    Last Post: 10-22-2006, 08:58 AM
Linkedin       Facebook       Twitter       RSS       Flickr       YouTube