Answer the question
In order to leave comments, you need to log in
Why does the request take much longer to resolve an IPv6 address?
Hello.
I'm making requests to my domain from a C++ application.
Requests are made using functions from WinInet.h, that is,
InternetOpen -> InternetConnect -> HttpOpenRequest -> HttpSendRequest
I noticed that for some people requests are executed instantly, for others it takes a very long time (about 20-30 seconds per request). Found out that the point is which address is resolved. If it's ipv6, then everything is slow. If I am on a machine where the ipv6 address is resolved by hand, I prescribe the domain address in hosts ipv4, then everything starts working very quickly.
I honestly googled but didn't find anything similar.
Here is a code snippet:
hInet = InternetOpen(string("MyApp/" + AppVersionAsString).c_str(), INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
if (!hInet) return false;
hConn = InternetConnect(hInet, appDomain.c_str(), 80, NULL, NULL, INTERNET_SERVICE_HTTP, 0, dwContext);
if (!hConn) return false;
DWORD dwFlags = INTERNET_FLAG_NO_CACHE_WRITE | INTERNET_FLAG_NO_COOKIES | INTERNET_FLAG_NO_UI | INTERNET_FLAG_PRAGMA_NOCACHE;
hReq = HttpOpenRequest(hConn, "POST", path.c_str(), "HTTP/1.1", NULL, rgpszAcceptTypes, dwFlags, dwContext);
DWORD connectTimeout = 5000;
InternetSetOption(hReq, INTERNET_OPTION_CONNECT_TIMEOUT, &connectTimeout, sizeof(connectTimeout));
bSuccess = HttpSendRequest(hReq, headers.c_str(), headers.length(), (LPVOID)PostData.c_str(), PostData.size());
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question