#1 2017-12-08 18:48:09

jaclas
Member
Registered: 2014-09-12
Posts: 215

Problem with WinHTTP client - error 87

I discovered that on some systems (our customers) client  on WinHTTP get error:

EWinHTTP ("winhttp.dll error 87 (The parameter is incorrect)")

but WinINet client works properly, why?

Last edited by jaclas (2017-12-12 13:04:15)

Offline

#2 2017-12-08 19:07:27

jaclas
Member
Registered: 2014-09-12
Posts: 215

Re: Problem with WinHTTP client - error 87

btw You have doubled const defined:

k9YNpew0.png

Offline

#3 2017-12-08 19:53:55

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

Re: Problem with WinHTTP client - error 87

jaclas wrote:

I discovered that on some systems (our customers) client  on WinHTTP get error:
but WinINet client works properly, why?

Never seen it in practice yet.

On which Windows version does it occur?

With which exact version of the framework (current is 1.18.4060)?

Offline

#4 2017-12-08 20:45:06

jaclas
Member
Registered: 2014-09-12
Posts: 215

Re: Problem with WinHTTP client - error 87

Windows 10 and latest mORMot.

Offline

#5 2017-12-08 22:44:16

EMartin
Member
From: Buenos Aires - Argentina
Registered: 2013-01-09
Posts: 337

Re: Problem with WinHTTP client - error 87

I think that it's related with new win HTTP API units of websockets from @mpv


Esteban

Offline

#6 2017-12-09 08:20:35

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

Re: Problem with WinHTTP client - error 87

I'm not able to reproduce it with Windows 10 and mORMot 1.18.4060.

More info is needed: the exact OSVersion content, the API call which fails, etc...

Offline

#7 2017-12-09 11:06:15

jaclas
Member
Registered: 2014-09-12
Posts: 215

Re: Problem with WinHTTP client - error 87

Ok, I will collect this data on monday

Offline

#8 2017-12-09 14:14:10

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

Re: Problem with WinHTTP client - error 87

EMartin wrote:

I think that it's related with new win HTTP API units of websockets from @mpv

Yes, I think too... sad

Offline

#9 2017-12-09 15:18:11

EMartin
Member
From: Buenos Aires - Argentina
Registered: 2013-01-09
Posts: 337

Re: Problem with WinHTTP client - error 87

Winhttp.dll have two constants definition in syncrtsock.pas: winhttpdll and winhttp_dll, I think that the problem Is there.


Esteban

Offline

#10 2017-12-09 15:45:50

mpv
Member
From: Ukraine
Registered: 2012-03-24
Posts: 1,571
Website

Re: Problem with WinHTTP client - error 87

I'm unable  to debug something till 12.12.2017. On vacation without PC. May be I merge some constant incorrectly... But Original code from winhttp brunch work on production during many month. More details about problem required..

Offline

#11 2017-12-11 13:36:31

jaclas
Member
Registered: 2014-09-12
Posts: 215

Re: Problem with WinHTTP client - error 87

First report from customer:

14:20:44.20: System: Windows Vista SP2 (6.0.6002)
14:20:50.20: mORMot [ver.1.18.4061] client TSQLHttpClientWinHTTP test....
14:20:51.20: Trying connect to REST server ...
14:20:51.20: 20171211 13205102  +    mORMotHttpClient.TSQLHttpClientWinHTTP(03A54630).CallBackGet Companies/Timestamp
14:20:51.20: 20171211 13205112 + mORMotHttpClient.TSQLHttpClientWinHTTP(03A54630).007F7FBC 
                                                       mORMotHttpClient.TSQLHttpClientGeneric.InternalURI (525) 
14:20:51.20: 20171211 13205122 EXC EWinHTTP ("winhttp.dll error 87 (Parametr jest niepoprawny)") at 00694735 
                                                          SynCrtSock.RaiseLastModuleError (3656)  stack trace API 00694735 
                                                          SynCrtSock.RaiseLastModuleError (3656) 0069ACD5 
                                                          SynCrtSock.TWinHTTP.InternalConnect (10025) 00699631 
                                                          SynCrtSock.THttpRequest.Create (9423) 007F9CA8 
                                                          mORMotHttpClient.TSQLHttpClientRequest.InternalCheckOpen (916) 007F7FCC 
mORMotHttpClient.TSQLHttpClientGeneric.InternalURI (527) 007AB0BA mORMot.CallInternalURI (37775) 

"Parametr jest niepoprawny" in polish mean "The parameter is incorrect"

Offline

#12 2017-12-12 13:23:14

mpv
Member
From: Ukraine
Registered: 2012-03-24
Posts: 1,571
Website

Re: Problem with WinHTTP client - error 87

@jaclas - I don't have a Windows Vista. If you can - please, debug a TWinHTTP.InternalConnect to determine a function what fail.
I see two potential error place:
- If you use a HTTPs the problem may be in TLS1.2 enabled in WINHTTP_FLAG_SECURE_PROTOCOL_MODERN flags
- if you use a proxy may be WinHttpAPI.Open fail because if incorrect OpenType option

But hard to say exactly without having access to environment where exception occurred

Offline

#13 2017-12-12 14:28:31

jaclas
Member
Registered: 2014-09-12
Posts: 215

Re: Problem with WinHTTP client - error 87

I don't have Vista, problem occurs on our customer station (I have access only to his log file).
Yes, I use SSL connection. I don't use proxy.

Offline

#14 2017-12-12 14:54:13

mpv
Member
From: Ukraine
Registered: 2012-03-24
Posts: 1,571
Website

Re: Problem with WinHTTP client - error 87

Can you comment a line in SynCrtSock

    WINHTTP_FLAG_SECURE_PROTOCOL_MODERN: DWORD =
      WINHTTP_FLAG_SECURE_PROTOCOL_SSL3
         or WINHTTP_FLAG_SECURE_PROTOCOL_TLS1
         //or WINHTTP_FLAG_SECURE_PROTOCOL_TLS1_1 or WINHTTP_FLAG_SECURE_PROTOCOL_TLS1_2; <--- commented line

and check recompiled code on customer station?

Offline

#15 2017-12-12 15:05:51

jaclas
Member
Registered: 2014-09-12
Posts: 215

Re: Problem with WinHTTP client - error 87

Yes, you are right, I add more logs and problem occurs in line:

    if not WinHttpAPI.SetOption(fSession, WINHTTP_OPTION_SECURE_PROTOCOLS,
       @WINHTTP_FLAG_SECURE_PROTOCOL_MODERN, SizeOf(WINHTTP_FLAG_SECURE_PROTOCOL_MODERN)) then
      RaiseLastModuleError(winhttpdll,EWinHTTP);

How resolve this issue?

Offline

#16 2017-12-12 15:11:08

jaclas
Member
Registered: 2014-09-12
Posts: 215

Re: Problem with WinHTTP client - error 87

After commented this line TWinHTTP client connect properly. And what now?

Offline

#17 2017-12-12 15:49:13

mpv
Member
From: Ukraine
Registered: 2012-03-24
Posts: 1,571
Website

Re: Problem with WinHTTP client - error 87

I'm fix it and commit ASAP (something wrong with master fossil repo - I got a *** time skew *** server is slow)

Last edited by mpv (2017-12-12 15:50:52)

Offline

#18 2017-12-12 19:10:39

mpv
Member
From: Ukraine
Registered: 2012-03-24
Posts: 1,571
Website

Re: Problem with WinHTTP client - error 87

Fix committed - see [b0c526a5b9]. @jaclas- thanks for help with debugging

Offline

Board footer

Powered by FluxBB