luasocket icon indicating copy to clipboard operation
luasocket copied to clipboard

persistent connection

Open gitdhar opened this issue 6 years ago • 1 comments

I see that the client doing, http.request() creates and tears down a new connection to the server. When there is a ongoing stream of http data to be sent (POSTs), is it possible to use a persistent TCP connection (conn reuse) and avoid this overhead each time?

gitdhar avatar Nov 07 '18 16:11 gitdhar

This is something I have considered in the past, but never had the chance to try. One possibility would be to override the "open" field to contain a function that returns a previously connected socket. Make sure to override the "connection" header to "keep-alive". Then you could potentially invoke request repeatedly. There may be a few quirks to sort out, but maybe this works. If you want to try it and suggest modifications that would enable this to work for real, you are very welcome. :)

diegonehab avatar Nov 07 '18 16:11 diegonehab