microsoft / cpprestsdk

The C++ REST SDK is a Microsoft project for cloud-based client-server communication in native code using a modern asynchronous C++ API design. This project aims to help C++ developers connect to and interact with services.
Other
8.01k stars 1.66k forks source link

Listener support for keep-alive #1197

Open mobileben opened 5 years ago

mobileben commented 5 years ago

In the midst of trying to figure out why network calls are so slow, It seems the code itself on the http server/listener side doesn't actually support keep-alive.

Are there any plans to support this? Or have I overlooked something?

garethsb commented 5 years ago

In what environment? Is this with ASIO-based http_listener or WinHttp-based? In both cases, I thought they were happily doing HTTP/1.1 and keep-alive by default...

mobileben commented 5 years ago

@garethsb-sony my bad sorry. For asio, I'm running this on Ubuntu 16.04. I did a grep for keep-alive (case insensitive) and found it only existed in the client as well as it did show up in the window http as a header string, however I don't think anything is really done with it.

There is an option that can be set for keep_alive (I've never used it, but I see it exists) with asio, but it isn't being used. I also don't see anything for changing timeouts.

I do see socket_base::reuse_address is being used, but I don't know if that suffices.

gpmn commented 4 years ago

@garethsb-sony does cpprestsdk support keep alive once it act as client?

garethsb commented 4 years ago

Hmm, there are a few inter-related things here, TCP keep-alive, HTTP keep-alive, support for HTTP pipelining, etc. As far as I know, http_listener and http_client don't explicitly close connections by default, so reuse is possible. However, as far as I can tell, there's nothing to handle the Keep-Alive response header directly, nor any support for HTTP pipelining. I'd really like to build support for HTTP pipelining on the client side, but haven't had the time to investigate other than deciding it would need an API modification as well as implementation work.

gpmn commented 4 years ago

@garethsb-sony Thank you! I'm eager to use the keep alive in client side to save a lot of resource, wish it could be supported as soon! B.R.