The server returned an invalid or unrecognized response

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
tPestitschek
Posts: 5
Joined: 21 Aug 2021, 01:17

The server returned an invalid or unrecognized response

Post by tPestitschek » 17 Jan 2022, 13:02

Hi everyone,

I have this piece of working code implemented & running for the past 9 months.
But recently, out of nowhere, the HTTP Request is no longer working.

Code: Select all

Error:  0x80072F78 - 
Source:        WinHttp.WinHttpRequest
Description:    The server returned an invalid or unrecognized response
This is just a simplified snippet of the code. Line 23 is returning the specified (above) exception
image.png
image.png (42.77 KiB) Viewed 851 times
1) WinHttp.WinHttpRquest.5.1 works fine for other endpoints
2) it affects both/all methods (GET, POST...)
3) the machine can effectively request the endpoint: no firewall or other troubles (requests works through python, postman, talend api, etc)
4) Changing the COM object from "WinHttp.WinHttpRequest.5.1" to "Msxml2.XMLHTTP" does fix the issue
5) once a day? once every 18 hours? HTTP request to the endpoint using ComObjCreate("WinHttp.WinHttpRequest.5.1") does work fine, only the subsequent calls fail (added this info on the OP)

Question is: why? Is there any way shape or form to proper debug the issue? I can/will do the change mentioned in item (4) but I would rather not, since it is basically creating a new branch of code that will be different than other scripts we have so far

Any help is most welcome.
Last edited by tPestitschek on 18 Jan 2022, 16:11, edited 1 time in total.

malcev
Posts: 1769
Joined: 12 Aug 2014, 12:37

Re: The server returned an invalid or unrecognized response

Post by malcev » 17 Jan 2022, 15:14

Try to set referer header.

tPestitschek
Posts: 5
Joined: 21 Aug 2021, 01:17

Re: The server returned an invalid or unrecognized response

Post by tPestitschek » 17 Jan 2022, 17:32

malcev wrote:
17 Jan 2022, 15:14
Try to set referer header.
There are two uris:
1st - the authentication endpoint (give basic auth, receive bearer token)
2nd - the effective API endpoint (give inputs, bearer token, do stuff)

I've set the header 'Referer' as suggested for the 1st URI even though it does not make much sense (what resource led me there? it is an API service, no "webpage" or whatever that human friendly directed me there)

Anyway, no luck, same error.

malcev
Posts: 1769
Joined: 12 Aug 2014, 12:37

Re: The server returned an invalid or unrecognized response

Post by malcev » 17 Jan 2022, 18:10

If You use windows 7, then
https://support.microsoft.com/en-us/top ... 268bb10392
Also may be need to set tls version manually, for example like this.

Code: Select all

HTTP.Option(9) := 0x80   ; TLS 1.0
What the site?

tPestitschek
Posts: 5
Joined: 21 Aug 2021, 01:17

Re: The server returned an invalid or unrecognized response

Post by tPestitschek » 18 Jan 2022, 15:39

malcev wrote:
17 Jan 2022, 18:10
If You use windows 7, then
https://support.microsoft.com/en-us/top ... 268bb10392
Also may be need to set tls version manually, for example like this.

Code: Select all

HTTP.Option(9) := 0x80   ; TLS 1.0
What the site?
No luck. Same error.

The site/endpoint is private (it is an intranet thing), can't really forward it to you since it'd require vpn connection

But I've found something interesting:
the first (once a day? once every 18 hours?) HTTP request to the endpoint using ComObjCreate("WinHttp.WinHttpRequest.5.1") does work fine, only the subsequent calls fail (added this info on the OP)

Post Reply

Return to “Ask for Help (v1)”