-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Rest Server Hanging Dead When Requested Concurrently #1147
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
Comments
Similar to #1144 |
You're doing a blocking task Do this instead: void handler::handle_post(http_request message)
{
ucout << message.to_string() << endl;
message.extract_json().then([message](pplx::task<json::value> value)
{
json::value body;
try {
body = value.get();
}
catch (std::exception&) {}
message.reply(status_codes::OK, message.to_string());
});
} |
I have the same problem as you, but my code as follow: first, I set the receive and send timeouts via http_listener_config like following: this is my httpserver class as follow:
}; //json parse
Does this cpprest sdk support the centos7.4 operating system? Why is this?I found that after the program runs for a while, multiple threads will enter each other and wait for each other to compete with std::unique_lock and can't quit, When this happens, httpserver will not be able to receive new messages. |
Same problem. You have a blocking |
Hi, first, I set the receive and send timeouts via http_listener_config like following: this is my httpserver class as follow:
}; //json parse
I found that after the program runs for a while, multiple threads will enter each other and wait for each other to compete with std::unique_lock and can't quit, When this happens, httpserver will not be able to receive new messages. Can you answer some useful suggestions from me? what shout i do? |
I also met the same problem, any way to solve it ? |
Do not perform blocking wait inside a listener handler, always use continuations. |
yes, Do not perform blocking wait inside a listener handler,you should use Asynchronous task chain when recv or send like this :
//------------------------------------- m_http_client->request(mtd, path_query_fragment, req_body_data).then([=](pplx::task<http_response> task) |
Spring Webflux detects blocking calls inside its threads and throws a run-time error. Can this be implemented in this project or generally in C++? |
If i had to wait for some response and perform further steps only after the request is completed, then what to do in that case . Also many cpprest blogs demonstrate to wait on the request object. Below is my code snippet and it seems to work for first few requests and then hangs. I dnt have access to server side code and seems server side code is there for many years. I am just writing the client side code
|
If i had to wait for some response and perform further steps only after the request is completed, then what to do in that case . Also many cpprest blogs demonstrate to wait on the request object. Below is my code snippet and it seems to work for first few requests and then hangs and it retrieves after few minutes . I dnt have access to server side code and seems server side code is there for many years. I am just writing the client side code
@garethsb can you pls mention if the issue for blocking is in server side or client side |
If i had to wait for some response and perform further steps only after the request is completed, then what to do in that case . Also many cpprest blogs demonstrate to wait on the request object. Below is my code snippet and it seems to work for first few requests and then hangs and it retrieves after few minutes . I dnt have access to server side code and seems server side code is there for many years. I am just writing the client side code
@garethsb can you pls tell you changed the code at client side or server side. |
When I send POST requests concurrently with >=200 threads, the rest server just stops response.
The handle_post is:
Please help me on this.
The text was updated successfully, but these errors were encountered: