Is it possible to use keep-alive http connection with XMLAPI?

pavel

Registered
Oct 3, 2010
2
0
51
Hi all,

I have tried to use keep-alive http header with XML-API:

Client->Server:


GET /xml-api/version HTTP/1.1
Host: myhost.com:2086
User-Agent: AutomationScript 1.0
Authorization: WHM root:0123456789abcdefgh<access hash goes here>
Keep-Alive: 300
Connection: keep-alive


Server->Client:

HTTP/1.1 200 OK
Server: cpsrvd/11.25
Connection: close
Transfer-Encoding: chunked
Content-type: text/xml

<version>
<version>11.26.8</version>
</version>

As you can see cPanel server closes the connection (Connection:close).
Is it possible to use keep-alive http connection with XMLAPI?
 

cPanelDavidN

Well-Known Member
Staff member
Dec 17, 2009
571
3
68
Houston, TX
cPanel Access Level
Root Administrator
Hi Pavel,

If I recall correctly, the 'Connection' header is determined by cpsrvd. And from practice, it can vary slightly between functions or WHM/cPanel version. Most of the time though I see my responses come back 'Connection:close'.

I'm not sure if this header is flexible in it's current implementation. What exactly is your issue? Maybe there's another solution? Or maybe there's something that is affecting the response that we can improve/investigate?

Regards,
-DavidN
 

pavel

Registered
Oct 3, 2010
2
0
51
Hi David,

Thank you for you response! I am trying to speed up the client-server conversation. It takes about 0.3 sec to open a new connection.
 

cPanelDavidN

Well-Known Member
Staff member
Dec 17, 2009
571
3
68
Houston, TX
cPanel Access Level
Root Administrator
It might be worth digging around in the Feature Request forum for a thread I recall. Someone requested that the XML-API could receive multiple API queries/actions within one request session. i.e., a call stack or job queue. The implementation of such a feature might use a keep-alive connection. Regardless, one of the primary objectives of such a feature is to make XML-API requests less expensive, and that is also one of your goals.

I know it doesn't solve your current situation, but it's something that might be available in the near future. You should try and hunt the Developer Discussion and Feature Request forums for that feature request, and throw in your vote of interest!

It may seem like a silly question, but are you connecting remotely or to the localhost? This is just a wild idea if you're remotely making your queries: if you can execute your XML-API queries faster on the local machine, you might investigate other means of triggering your script (on the localhost), say, a persistent SSH tunnel? I think there will be some trade-offs, but you might be able to squeeze something faster...again, it kinda depends.

Regards,
-DavidN