#1 2023-11-30 13:02:21

imperyal
Member
Registered: 2018-10-11
Posts: 50

Intermittent winhttp.dll error 12019

Hello everyone,

Our application has been experiencing some connection issues lately. And we are having a hard time figuring out why...

It doesn't happen on our headquarter's computers at all (Win10 and Win11), it happens on the clients, but not always, they will have trouble connecting (or requests fail mid-session) randomly.

When a request fails we find two different errors (with the same error code):
- winhttp.dll error 12019 (The handle is in the wrong state for the requested operation)
- winhttp.dll error 12019 (00002EF3)

It doesn't help the fact we can't debug this because we are not having the issue on our computers, and we never know on what client's computer it will happen...

We now have a dedicated server on a hosting company running the server application, before that, we used a VPS on another hosting company, and the issues persisted on this brand new dedicated server with new config, new SSL certificate, new domain, and IP.

I did find this topic: https://synopse.info/forum/viewtopic.php?id=5550

In our case the issue is intermittent, I guess it rules out the Proxy configuration.
We don't have the {$R Vista.res} resource on our .dpr project files, can this be it?

We are at a loss here...

Offline

#2 2023-11-30 15:21:36

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,203
Website

Re: Intermittent winhttp.dll error 12019

If you don't have Vista.res then Windows 10 won't be detected, but the project will still detect WIndows 7 so in fact TWinHttp.InternalConnect won't use WINHTTP_ACCESS_TYPE_AUTOMATIC_PROXY...
This is the only place when a missing Vista.res manifest could be relevant.

I have two questions:

1. Do the clients use a proxy?

2. Which class are you using on the client side for the connection?

Try to use new WinHttpForceProxyDetection global flag as true to force proxy detection (if your systems are WIndows 8.1 or newer):
https://github.com/synopse/mORMot2/commit/53de10b0
and https://github.com/synopse/mORMot2/commit/730ac233

Offline

#3 2023-11-30 15:48:11

imperyal
Member
Registered: 2018-10-11
Posts: 50

Re: Intermittent winhttp.dll error 12019

Thank you ab..

I think some clients use a proxy, but the majority don't...
Some clients report problems when using their home internet provider also (very simple direct PC-Router connection with no proxy)...

We use TSQLHttpClient (TSQLHttpClientWinHTTP) and TSQLRestClientURINamedPipe.
The change between local/cloud uses TSQLRestClientRedirect.

The issues only happen when TSQLRestClientRedirect is Redirect To TSQLHttpClient.

Offline

#4 2023-11-30 15:50:42

imperyal
Member
Registered: 2018-10-11
Posts: 50

Re: Intermittent winhttp.dll error 12019

We din't migrate to mORMot 2 yet...

Offline

#5 2023-11-30 16:01:35

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,203
Website

Re: Intermittent winhttp.dll error 12019

Try to use the socket client, then.

Offline

#6 2023-11-30 16:49:18

imperyal
Member
Registered: 2018-10-11
Posts: 50

Re: Intermittent winhttp.dll error 12019

The socket client ( TSQLHttpClientWinSock ? ) doesn't support SSL if I remember correctly...

Offline

#7 2023-11-30 17:44:06

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,203
Website

Re: Intermittent winhttp.dll error 12019

Ah you are right... not with mORMot 1.

Try to comment those lines:

procedure TWinHTTP.InternalConnect(ConnectionTimeOut,SendTimeout,ReceiveTimeout: DWORD);
var OpenType: integer;
    Callback: WINHTTP_STATUS_CALLBACK;
    CallbackRes: PtrInt absolute Callback; // for FPC compatibility
    protocols: DWORD;
begin
  if fProxyName='' then
    {if (OSVersionInfo.dwMajorVersion>6) or
       ((OSVersionInfo.dwMajorVersion=6) and (OSVersionInfo.dwMinorVersion>=3)) then
      OpenType := WINHTTP_ACCESS_TYPE_AUTOMATIC_PROXY else} // Windows 8.1 and newer
      OpenType := WINHTTP_ACCESS_TYPE_NO_PROXY else
    OpenType := WINHTTP_ACCESS_TYPE_NAMED_PROXY;

You could still use a proxy, with manual settings.

Offline

#8 2023-11-30 18:24:02

imperyal
Member
Registered: 2018-10-11
Posts: 50

Re: Intermittent winhttp.dll error 12019

I will do these changes and use TSQLHttpClient (TSQLHttpClientWinHTTP), correct?

Thank you for your help.

Offline

#9 2023-11-30 19:15:46

igors233
Member
Registered: 2012-09-10
Posts: 234

Re: Intermittent winhttp.dll error 12019

I had the same issue (same error) happening randomly while communicating to some API rest server. Never managed to find the cause: server, cliient, routers or CloudFlare. Solution I used was to reastablish connection and repeat the request.

Offline

Board footer

Powered by FluxBB