Sitelet https://web.archive.org/web/20201201011208/https://github.com/microsoft/cpprestsdk/issues/1460
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTTP Listener regularly hangs for ages until it calls the method handler function #1460

Open
maxluchterhand1 opened this issue Jul 5, 2020 · 0 comments

Comments

@maxluchterhand1
Copy link

@maxluchterhand1 maxluchterhand1 commented Jul 5, 2020 •

Hey,

I am trying currently trying to use the http_listener. While it does work, I am suffering from massive performance issues / hanging.
Some HTTP requests I throw against the http_listener are handled immediately, while others take up to 20 seconds. The request that hang are usually the first request made, as well as requests that are being made after a few seconds of no requests.

Here's an example of how I register the handlers and start the listener loop:

void HttpListener::registerMethodHandlers() {
    mListener.support(methods::POST, &HttpListener::spawnRequestHandler);
    mListener.support(methods::GET, &HttpListener::spawnRequestHandler);
    mListener.support(methods::PUT, &HttpListener::spawnRequestHandler);
    mListener.support(methods::DEL, &HttpListener::spawnRequestHandler);
}

void HttpListener::startLoop() {
        mListener.open().wait();
}

void HttpListener::spawnRequestHandler(http_request request) {
    std::thread handlerThread([request](){
        HttpRequestPreHandler handler(request);
        handler.handleRequest();
    });
    handlerThread.detach();
}

I am using cpprestsdk version v2.10.16 compiled on Arch.

I have not included the functions that are being called inside spawnRequestHandler in the code sample because the delay happens before spawnRequestHandler is called.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant
You can’t perform that action at this time.