lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

On 4 October 2010 02:55, Norbert Kiesel <> wrote:
> On Sun, 2010-10-03 at 22:28 -0300, Diego Nehab wrote:
>> Hi,
>> I have not tried to implement support for persistent connections in
>> LuaSocket because of the complications involved. I don't know how you
>> modified the API to support multiple requests per connection, so I
>> can't tell where it is going wrong. But if you use http.request(), it
>> will close the connection as soon as it done getting the response
>> body.
> I use luasoap with luasocket to send soap calls to VMware servers.  This
> overall works beautifully and functionality wise I'm a happy camper
> (having a wsdl->lua converter would be nice though, but that's a
> different topic).
> However, for even simple tasks I end up doing dozens of SOAP calls,
> ending up sometimes doing about 1000 calls within 5 minutes.  And all
> that over HTTPS (I added a little piece of code to the open method to
> call ssl.wrap on the socket). Right now even a simple call takes about
> 0.2 seconds, so I'm reaching the end of the line and I'm looking for
> speedups.  Trying to re-use the connection instead of re-creating it for
> every call was/is one of my ideas.
> Just to see if that would work, I tried to simply comment out all
> "close" calls I could find (in socke.lua and http.lua) to see if the
> server side would accepts the 2nd call over the same connection.  But
> somehow I'm missing one place, because the socket is still closed after
> the first request and I can't figure out where/how that happens.

As has been said earlier in the thread, even if you remove all close()
calls the server can still close the connection after sending the
response, and it probably does. Unless the server and client both
support HTTP 1.1 persistent connections then expect the connection to

As Diego said, LuaSocket doesn't support HTTP 1.1 persistent
connections, and I don't know a Lua HTTP library that does (not that I
can claim to have exhaustively searched). If you're sure your server
supports them then it may be worth implementing.

Alternatively I have a HTTP client library that might be easier to
adapt. I've not tested it with persistent connections, but it may be
easier to extend to do so. The library is part of Prosody, but I have
a project here that pulls the HTTP library into something standalone: (it uses Squish to pull in and a couple
of others).

It's on my todo to implement myself at some point, but I don't have
time right now.


PS. Is the RPC server a part of VMware? I'm wondering if HTTP is
actually requirement... :)