-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Request Lost when using SSL #1825
Comments
@nanjo712 could you make a unit test that can reproduce the problem in |
I tried unit testing but was unable to reproduce the bug. When I attempted to test with Python and other languages, I did not encounter the same issue either. It seems that this problem only occurs with Postman. TEST(SSLTest, SSLTest1) {
SSLServer svr(SERVER_CERT_FILE, SERVER_PRIVATE_KEY_FILE);
ASSERT_TRUE(svr.is_valid());
svr.Get("/hi", [](const Request & /*req*/, Response &res) {
res.set_content("Hello World!", "text/plain");
});
std::thread t([&]() { svr.listen(HOST, 8443); });
auto se = detail::scope_exit([&] {
svr.stop();
t.join();
ASSERT_FALSE(svr.is_running());
});
svr.wait_until_ready();
auto func = []() {
SSLClient cli("localhost", 8443);
cli.enable_server_certificate_verification(false);
for (int i = 0; i < 100; i++) {
auto res = cli.Get("/hi");
ASSERT_TRUE(res);
EXPECT_EQ(StatusCode::OK_200, res->status);
EXPECT_EQ("Hello World!", res->body);
}
};
std::vector<std::thread> threads;
for (int i = 0; i < 10; i++) {
threads.emplace_back(func);
}
for (auto &t : threads) {
t.join();
}
} it will pass the test. Perhaps this library has some compatibility issues with Postman |
When Postman get an Error, it shows message like this. |
If I remove the "Connection: keep-alive" from the header, this problem will disappear. I think that‘s the problem |
I also encountered a similar problem. Removing header Connection: keep-alive can fix the problem. Does that mean removing this header from the postman side? |
Yes, just remove the header in Postman. That fix the problem. |
@yhirose I try the test TEST(KeepAliveTest, SSLClientReconnection) on my machine. The program did not pass the test |
That's the log. The code in line 4988 is
|
I'll close it since you found the solution. |
I am trying to build an HTTP server with SSL using httplib, and I have generated an SSL certificate using OpenSSL, something like this: httplib::SSLServer server("server.crt", "server.key");. When I send a large number of requests using Postman for testing, two-thirds of the requests are consistently lost. Strangely, this two-thirds ratio is almost stable, meaning that no matter how many threads I use, each thread will lose two-thirds of its requests. What's even more peculiar is that if I start 10 threads at the same time and only send one request per thread, all requests receive responses.
This phenomenon is not limited to local HTTP requests; remote requests have the same issue, exhibiting the exact same behavior. However, once I disable SSL, all instances of request loss disappear.
The text was updated successfully, but these errors were encountered: