C++에서 libcurl을 사용하여 페이지의 데이터를 가져 오지만 vps에 연결할 때 어떤 이유로 인해 게시물 제목에 오류가 발생합니다. vps의 코드는 요청을 받고 데이터베이스의 일부 데이터를 출력합니다. curl_easy_perform() failed : 서버에 연결할 수 없습니다.
#include "requestMapper.hpp"
// Send a GET request to API to retreive image
void RequestMapper::retreiveData(std::string url) {
CURL *curl;
CURLcode res;
curl_global_init(CURL_GLOBAL_DEFAULT);
curl = curl_easy_init();
if(curl) {
ISSUE HERE // curl_easy_setopt(curl, CURLOPT_URL, "https://104.236.200.91/index.php/food/");
res = curl_easy_perform(curl);
#ifdef SKIP_PEER_VERIFICATION
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);
#endif
#ifdef SKIP_HOSTNAME_VERIFICATION
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L);
#endif
res = curl_easy_perform(curl);
if (res != CURLE_OK)
fprintf(stderr, "curl_easy_perform() failed: %s\n", curl_easy_strerror(res));
curl_easy_cleanup(curl);
}
curl_global_cleanup();
}
// Submit a post request to API link to send data
void RequestMapper::postData() {
}
int main(void) {
RequestMapper rm;
rm.retreiveData("sample");
return 0;
}
이 코드
URL이 " https://google.com"와 같은 일이있을 때 잘 작동하지만 내 웹 서버에 대한 링크를 쳤을 때 나는 그 오류가 설정합니다. 나는이 도서관보다 최신이지만, 나는 올바르게 일한다고 생각했다. 누구나 통찰력이 있다면 알려주세요! 이 문제를 계속 고치고 해결책을 찾으면 여기서 공유 할 것입니다.감사합니다.
편집 :
는 최근이 문제를 해결하고이 게시물에 우연히 있습니다 사람과 공유하고 싶었다. 대신 http://URL
을 사용해야했을 때 https://URL
을 사용하고 있었으므로이 문제가 발생하면 먼저 사용하십시오. 오류 7의