We are receiving 12156 error while making Api call from winhttp library
One of our customer receiving 12156 while making Api call from our application using proxy. But same Api call working well from PowerShell invoke-restmethod at customer and from same machine while using proxy. Our application is using WinHttp cpp methods to make http call. Some code samples as below.
HINTERNET hReq = WinHttpOpenRequest(
hConn,
method.c_str(),
path.c_str(),
NULL, // Should default to 1.1
WINHTTP_NO_REFERER,
WINHTTP_DEFAULT_ACCEPT_TYPES,
flags);
WinHttpSetOption(hReq,
WINHTTP_OPTION_PROXY,
&ProxyInfo,
cbProxyInfoSize)
customer proxy info type is WINHTTP_ACCESS_TYPE_NAMED_PROXY.
Customer received 12156 error as below
Trying to receive HTTP Response
Failure in receiving HTTP Response, error: 12156
Trying to retrieve HTTP Query Headers
Failure in retrieving HTTP Query Headers, error: 12019
We tried different options to reproduce 12156 error but not able to reproduce.
Only one way we were able to reproduce at our end setting max redirects < Original Api redirects
like below.
DWORD maxRedirects = 0;
if (!WinHttpSetOption(hReq_noproxy,
WINHTTP_OPTION_MAX_HTTP_AUTOMATIC_REDIRECTS,
&maxRedirects,
sizeof(maxRedirects)))
{
Default max redirects value is 10 (Not changed in our application). And our Api using only 1 redirect. Could you please suggest is there any other cases can we get 12156 while using proxy through WinHttp library.