opened
ihmc3jn09hk
username_0
Haven't been updated for a while. Unfortunately it is a bug report.

**Describe the bug**
Using HttpClient as drogon::plugin. The application crashes on some particular urls.


**To Reproduce**
Steps to reproduce the behavior:
1. Create a plugin with the `drogon_ctl`, e.g. Pulgin
2. Send requests by HttpClient in the `initAndStart` function, e.g.

```c++
void Pulgin::initAndStart(const Json::Value &config)
{
        LOG_DEBUG << "Start Plugin";
  	static auto func_resp = [](drogon::ReqResult res, const drogon::HttpResponsePtr &resp){
		if ( drogon::ReqResult::Ok != res ){
			LOG_WARN << "GG : " << static_cast<int>(res) << " ";
			return;
		}
		LOG_INFO << "MKay";
	};
        static auto func_req = [](const std::string &domain, const std::string &path){
		auto url{domain+path};
		auto clientPtr_ = 
			drogon::HttpClient::newHttpClient(
				"https://"+domain
			);
		clientPtr_->enableCookies();
		auto req_ = drogon::HttpRequest::newHttpRequest();
		req_->setMethod(drogon::Get);
		req_->setPath(path);
		
		clientPtr_->sendRequest(req_, func_resp, 10);
	};
        std::vector<std::string> targetUrls;
        //Crashing URLs
        targetUrls.emplace_back("medium.com/better-programming/understand-5-scopes-of-pytest-fixtures-1b607b5c19ed");
	targetUrls.emplace_back("tutorialedge.net/golang/improving-your-tests-with-testify-go");
	targetUrls.emplace_back("code.tutsplus.com/articles/rspec-testing-for-beginners-part-1--cms-26716");
	targetUrls.emplace_back("proandroiddev.com/testing-with-koin-ade8a46eb4d");
	targetUrls.emplace_back("ieftimov.com/post/testing-in-go-go-test");
        
/*     E.g. Ok URLs
	targetUrls.emplace_back("github.com/stretchr/testify");
	targetUrls.emplace_back("sysout.ru/testirovanie-kontrollerov-s-pomoshhyu-mockmvc");
	targetUrls.emplace_back("www.youtube.com/watch?v=8S8o46avgAw");
	targetUrls.emplace_back("changhsinlee.com/pytest-mock");
*/
       //Loop through all the urls
	for ( size_t i=0; i<targetUrls.size(); ++i ){
		const std::string &url = targetUrls[i];
		auto pos = url.find("/");
		func_req(url.substr(0, pos),
			    url.substr(pos));
	}
}
```

3. Run the app

```console
20210214 14:26:12.445951 UTC 9509 DEBUG [initAndStart] Start Plugin - Pulgin.cc:36
20210214 14:26:12.445978 UTC 9509 DEBUG [operator()] medium.com/better-programming/understand-5-scopes-of-pytest-fixtures-1b607b5c19ed - Pulgin.cc:48
20210214 14:26:12.446506 UTC 9509 DEBUG [operator()] tutorialedge.net/golang/improving-your-tests-with-testify-go - Pulgin.cc:48
20210214 14:26:12.446903 UTC 9509 DEBUG [operator()] code.tutsplus.com/articles/rspec-testing-for-beginners-part-1--cms-26716 - Pulgin.cc:48
20210214 14:26:12.447242 UTC 9509 DEBUG [operator()] proandroiddev.com/testing-with-koin-ade8a46eb4d - Pulgin.cc:48
20210214 14:26:12.447656 UTC 9509 DEBUG [operator()] ieftimov.com/post/testing-in-go-go-test - Pulgin.cc:48
Segmentation fault

```

**Expected behavior**
```console
20210214 14:31:39.445951 UTC 9509 DEBUG [initAndStart] Start Plugin - Pulgin.cc:36
20210214 14:31:39.464824 UTC 9596 DEBUG [operator()] github.com/stretchr/testify - Pulgin.cc:48
20210214 14:31:39.465412 UTC 9596 DEBUG [operator()] sysout.ru/testirovanie-kontrollerov-s-pomoshhyu-mockmvc - Pulgin.cc:48
20210214 14:31:39.465763 UTC 9596 DEBUG [operator()] www.youtube.com/watch?v=8S8o46avgAw - Pulgin.cc:48
20210214 14:31:39.466133 UTC 9596 DEBUG [operator()] changhsinlee.com/pytest-mock - Pulgin.cc:48
20210214 14:31:39.509395 UTC 9596 INFO  MKay - Pulgin.cc:44
20210214 14:31:39.834578 UTC 9596 INFO  MKay - Pulgin.cc:44
20210214 14:31:39.851334 UTC 9596 INFO  MKay - Pulgin.cc:44
20210214 14:31:45.271886 UTC 9596 INFO  MKay - Pulgin.cc:44

```

**Desktop (please complete the following information):**
 - OS: Linux

**Additional context**
Has no clue why is it related to the urls ? Those crashing urls are normal urls which are found from google randomly. They work just fine with Firefox and chrome.
HttpClient crashes on some urls
issue
created
an-tao
username_1
@username_0 The PR #717 fixed the crash of this issue, it's because the SSL handshake fails, but I have no idea of why some URLs can't be connected with SSL of Drogon.
comment
created
ihmc3jn09hk
username_0
@username_1 Thank you for the quick reaction. I shall be fixing this.
Will test it later.
comment
closed
an-tao
username_1
issue
reopened
an-tao
username_1
Haven't been updated for a while. Unfortunately it is a bug report.

**Describe the bug**
Using HttpClient as drogon::plugin. The application crashes on some particular urls.


**To Reproduce**
Steps to reproduce the behavior:
1. Create a plugin with the `drogon_ctl`, e.g. Pulgin
2. Send requests by HttpClient in the `initAndStart` function, e.g.

```c++
void Pulgin::initAndStart(const Json::Value &config)
{
        LOG_DEBUG << "Start Plugin";
  	static auto func_resp = [](drogon::ReqResult res, const drogon::HttpResponsePtr &resp){
		if ( drogon::ReqResult::Ok != res ){
			LOG_WARN << "GG : " << static_cast<int>(res) << " ";
			return;
		}
		LOG_INFO << "MKay";
	};
        static auto func_req = [](const std::string &domain, const std::string &path){
		auto url{domain+path};
		auto clientPtr_ = 
			drogon::HttpClient::newHttpClient(
				"https://"+domain
			);
		clientPtr_->enableCookies();
		auto req_ = drogon::HttpRequest::newHttpRequest();
		req_->setMethod(drogon::Get);
		req_->setPath(path);
		
		clientPtr_->sendRequest(req_, func_resp, 10);
	};
        std::vector<std::string> targetUrls;
        //Crashing URLs
        targetUrls.emplace_back("medium.com/better-programming/understand-5-scopes-of-pytest-fixtures-1b607b5c19ed");
	targetUrls.emplace_back("tutorialedge.net/golang/improving-your-tests-with-testify-go");
	targetUrls.emplace_back("code.tutsplus.com/articles/rspec-testing-for-beginners-part-1--cms-26716");
	targetUrls.emplace_back("proandroiddev.com/testing-with-koin-ade8a46eb4d");
	targetUrls.emplace_back("ieftimov.com/post/testing-in-go-go-test");
        
/*     E.g. Ok URLs
	targetUrls.emplace_back("github.com/stretchr/testify");
	targetUrls.emplace_back("sysout.ru/testirovanie-kontrollerov-s-pomoshhyu-mockmvc");
	targetUrls.emplace_back("www.youtube.com/watch?v=8S8o46avgAw");
	targetUrls.emplace_back("changhsinlee.com/pytest-mock");
*/
       //Loop through all the urls
	for ( size_t i=0; i<targetUrls.size(); ++i ){
		const std::string &url = targetUrls[i];
		auto pos = url.find("/");
		func_req(url.substr(0, pos),
			    url.substr(pos));
	}
}
```

3. Run the app

```console
20210214 14:26:12.445951 UTC 9509 DEBUG [initAndStart] Start Plugin - Pulgin.cc:36
20210214 14:26:12.445978 UTC 9509 DEBUG [operator()] medium.com/better-programming/understand-5-scopes-of-pytest-fixtures-1b607b5c19ed - Pulgin.cc:48
20210214 14:26:12.446506 UTC 9509 DEBUG [operator()] tutorialedge.net/golang/improving-your-tests-with-testify-go - Pulgin.cc:48
20210214 14:26:12.446903 UTC 9509 DEBUG [operator()] code.tutsplus.com/articles/rspec-testing-for-beginners-part-1--cms-26716 - Pulgin.cc:48
20210214 14:26:12.447242 UTC 9509 DEBUG [operator()] proandroiddev.com/testing-with-koin-ade8a46eb4d - Pulgin.cc:48
20210214 14:26:12.447656 UTC 9509 DEBUG [operator()] ieftimov.com/post/testing-in-go-go-test - Pulgin.cc:48
Segmentation fault

```

**Expected behavior**
```console
20210214 14:31:39.445951 UTC 9509 DEBUG [initAndStart] Start Plugin - Pulgin.cc:36
20210214 14:31:39.464824 UTC 9596 DEBUG [operator()] github.com/stretchr/testify - Pulgin.cc:48
20210214 14:31:39.465412 UTC 9596 DEBUG [operator()] sysout.ru/testirovanie-kontrollerov-s-pomoshhyu-mockmvc - Pulgin.cc:48
20210214 14:31:39.465763 UTC 9596 DEBUG [operator()] www.youtube.com/watch?v=8S8o46avgAw - Pulgin.cc:48
20210214 14:31:39.466133 UTC 9596 DEBUG [operator()] changhsinlee.com/pytest-mock - Pulgin.cc:48
20210214 14:31:39.509395 UTC 9596 INFO  MKay - Pulgin.cc:44
20210214 14:31:39.834578 UTC 9596 INFO  MKay - Pulgin.cc:44
20210214 14:31:39.851334 UTC 9596 INFO  MKay - Pulgin.cc:44
20210214 14:31:45.271886 UTC 9596 INFO  MKay - Pulgin.cc:44

```

**Desktop (please complete the following information):**
 - OS: Linux

**Additional context**
Has no clue why is it related to the urls ? Those crashing urls are normal urls which are found from google randomly. They work just fine with Firefox and chrome.
HttpClient crashes on some urls
issue
created
ihmc3jn09hk
username_0
@username_1 #717 prevents crashes. But the handshake part is quite wierd. 
https://github.com/username_1/trantor/blob/e35fd046ac8a58bec3557c0c207a3e0b8ae57d38/trantor/net/inner/TcpConnectionImpl.cc#L1411
comment
created
an-tao
username_1
Yes, I knew this and I'm trying to resolve it.
comment
created
marty1885
username_2
@username_0 What do you mean by weird?
comment
created
an-tao
username_1
@username_0 After some investigations, I thought the issue is related to SNI and made a PR #724 to resolve this, please check it out. thanks.
comment
closed
an-tao
username_1
issue
created
ihmc3jn09hk
username_0
@username_2 I am sorry for missing your comment. That was related the header of the request. I compared the headers of requests from drogon and Chrome/Firefox, there is one not included, "Hostname". I thought was related to this and added this header in drogon but still failed since the actual problem is at the handshake part.

@username_1 Thank you very much. Will test it out later.
comment
created
ihmc3jn09hk
username_0
@username_1 All the urls posted can be accessed now. Thank you.
comment