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.

Connection timed out when using xml-api

Discussion in 'cPanel Developers' started by dom974, Aug 22, 2007.

  1. dom974

    dom974 Active Member

    Joined:
    Jun 24, 2007
    Messages:
    41
    Likes Received:
    0
    Trophy Points:
    6
    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. 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
    Is the script located on the same server as the WHM interface the API is attempting to interface with (localhost) or another server?
     
  3. dom974

    dom974 Active Member

    Joined:
    Jun 24, 2007
    Messages:
    41
    Likes Received:
    0
    Trophy Points:
    6
    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. 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
    What about port 2086 (if using HTTP) or 2087 (if using HTTPS) which are used by the XML-API?
     
  5. dom974

    dom974 Active Member

    Joined:
    Jun 24, 2007
    Messages:
    41
    Likes Received:
    0
    Trophy Points:
    6
    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. 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
    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.php?p=312310&postcount=14
     
  7. dom974

    dom974 Active Member

    Joined:
    Jun 24, 2007
    Messages:
    41
    Likes Received:
    0
    Trophy Points:
    6
    Doh, still the same "connection timed out" issue :confused:

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

    Dominique
     
  8. 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
    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. dom974

    dom974 Active Member

    Joined:
    Jun 24, 2007
    Messages:
    41
    Likes Received:
    0
    Trophy Points:
    6
    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):
    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
     
    #9 dom974, Aug 23, 2007
    Last edited: Aug 23, 2007
Loading...

Share This Page