Hello!
I've got a problem with the http components and the http keepalive. Following all documentation I found the tcp session to the server should be kept connected if the http version is 1.1 and keepalive is set to true. My approach is the following:
Server side:
// Initialize HTTP-Server
ServerSocket svs(CGlobals::HTTP_Port);
HTTPServerParams* params = new HTTPServerParams();
params->setKeepAlive(true);
Poco::Timespan spanKeepAlive(30, 0);
params->setKeepAliveTimeout(spanKeepAlive);
params->setMaxKeepAliveRequests(1000000);
m_HTTPServer = new HTTPServer(new CRequestHandlerFactory(this), *m_HTTPPool, svs, params);
Client side
// Initialize HTTP client
SocketAddress addr(CGlobals::SkeletonAddr); // default address
m_client = new HTTPClientSession(addr);
m_client->setKeepAlive(true);
Poco::Timespan spanKeepAlive(30, 0);
m_client->setKeepAliveTimeout(spanKeepAlive);
Performin the Request:
// Prepare Request
HTTPRequest* request = new HTTPRequest("POST", "ktsod", "1.1");
request->setContentType("text/json; charset=ISO-8859-1");
request->setKeepAlive(true);
ostream& outStream = m_client->sendRequest(*request);
And in the request handler:
response.setVersion("1.1");
response.setKeepAlive(true);
However, an inspection of network traffic shows that a new tcp connection is established for every request (with the same HTTPClientSession of course)
So, how can I make HTTPKeepAlive work?
brgds
Sven Weiberg




