|
From: | Derrick Bradbury |
Subject: | [libmicrohttpd] Connection: Keep-Alive |
Date: | Wed, 7 Aug 2013 19:28:27 +0000 |
Hi all...
I've been putting together an app that requires a persistant connection for 30 seconds, drop and re-establish. Everything is working except for the keepalive... >From everything I've read, HTTP/1.1 should have keepalive enabled by default, and in MHD, you must close it by adding the header (Connection: close). Problem is, that when I get a request, the header has a "keep-alive" request, but MHD returns a "Connection: close"... * About to connect() to 127.0.0.1 port 5000 (#0) * Trying 127.0.0.1... connected * Connected to 127.0.0.1 (127.0.0.1) port 5000 (#0) > GET /ready.html HTTP/1.1 > User-Agent: curl/7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.14.0.0 zlib/1.2.3 libidn/1.18 libssh2/1.4.2 > Host: 127.0.0.1:5000 > Accept: */* > Connection: Keep-Alive > < HTTP/1.1 200 OK < Connection: close < Content-Length: 2 < 1 * Closing connection #0 * About to connect() to 127.0.0.1 port 5000 (#0) * Trying 127.0.0.1... connected * Connected to 127.0.0.1 (127.0.0.1) port 5000 (#0) > GET /classify.html?url="" HTTP/1.1 > User-Agent: curl/7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.14.0.0 zlib/1.2.3 libidn/1.18 libssh2/1.4.2 > Host: 127.0.0.1:5000 > Accept: */* > Connection: Keep-Alive > < HTTP/1.1 200 OK < Connection: close < Content-Length: 6 < 33 66 * Closing connection #0 If I manually add a "Connection: Keep-Alive" header, the client thinks there should be a persistant connection, but the server still closes the connection: * About to connect() to 127.0.0.1 port 5000 (#0) * Trying 127.0.0.1... connected * Connected to 127.0.0.1 (127.0.0.1) port 5000 (#0) > GET /ready.html HTTP/1.1 > User-Agent: curl/7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.14.0.0 zlib/1.2.3 libidn/1.18 libssh2/1.4.2 > Host: 127.0.0.1:5000 > Accept: */* > Connection: Keep-Alive > < HTTP/1.1 200 OK < Content-Length: 2 < Connection: keep-alive < 1 * Connection #0 to host 127.0.0.1 left intact * Connection #0 seems to be dead! * Closing connection #0 * About to connect() to 127.0.0.1 port 5000 (#0) * Trying 127.0.0.1... connected * Connected to 127.0.0.1 (127.0.0.1) port 5000 (#0) > GET /classify.html?url="" HTTP/1.1 > User-Agent: curl/7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.14.0.0 zlib/1.2.3 libidn/1.18 libssh2/1.4.2 > Host: 127.0.0.1:5000 > Accept: */* > Connection: Keep-Alive > < HTTP/1.1 200 OK < Content-Length: 4 < Connection: keep-alive < 998 * Connection #0 to host 127.0.0.1 left intact * Connection #0 seems to be dead! * Closing connection #0 Here is my daemon definition: daemon = MHD_start_daemon (MHD_USE_SELECT_INTERNALLY | MHD_SUPPRESS_DATE_NO_CLOCK | MHD_USE_EPOLL_LINUX_ONLY | MHD_USE_EPOLL_TURBO, options.port, NULL, NULL, &answer_to_connection, NULL, MHD_OPTION_THREAD_POOL_SIZE, (unsigned int) options.threads, MHD_OPTION_CONNECTION_LIMIT, (unsigned int) 12000, MHD_OPTION_END); and my response being built: response = MHD_create_response_from_buffer (strlen (page), (void*) page, MHD_RESPMEM_PERSISTENT); ret = MHD_add_response_header(response,"Connection","keep-alive"); ret = MHD_queue_response (connection, MHD_HTTP_OK, response); MHD_destroy_response (response); Am I needing a different response, or setting? Thanks! Derrick |
[Prev in Thread] | Current Thread | [Next in Thread] |