indiscripts/IdExtenso

No result from XMLHTTP: Access is denied.

CharlieNH opened this issue · 9 comments

Hi, Marc. IdExtenso had been pulling my Google Doc files into an InDesign script brilliantly since February until suddenly, sometime in August, it started consistently throwing this error: "[HTTPS] No result from XMLHTTP: Access is denied."

I've tried tweaking the Google Docs URLs we pass into $$.Web() every way I can think of. Every URL I try fails with that same error, yet every one works fine from Chrome, even when I'm not logged into my Google account.

I have no reason to think this is a problem with IdExtenso (I'm running 210901), but just in case this is something you should know about, I'm passing this information along to you.

I've attached a quick-and-dirty testing harness. (I changed the file extension from .jsx to .txt so I could attach it.)

  1. Run it and give it the URL indiscripts.com -- it should $.writeln the first 100 characters of your home page.
  2. Run it and give it this URL:
    https://docs.google.com/document/d/1fFt1u5IUhdRDKrzpD7ZiZfEcs5_aopqxBAVm4pyvuhg
  3. It should fail, as described above.
  4. Paste that same URL into your browser. Our Google Doc should appear with no problem.

Hopefully you'll see the same problem I'm seeing. If you have any ideas about what's going on and/or how I can fix it, I'd love to hear them!

Thanks,

Charlie

myExperiments - Stub for Marc.txt

I can confirm the issue. Win 10/ID CC 2021

@marc Im always interested in getting HTTP-Connections in ExtendScript. I do maintain https://github.com/grefel/restix which uses MSXML2.ServerXMLHTTP.6.0 for the HTTPS call. It does work with the URL mentioned above. I see you experimented with the same:

// 'MSXML2.XMLHTTP' works fine in CS4-CC ; // 'MSXML2.ServerXMLHTTP.6.0' might sometimes work better // but causes problems in CS4.
:-(

So maybe do not use it with CS4 only?

@CharlieNH Hi Charlie,

Thanks for your feedback. I also confirm the issue you reported, getting the following log in TRACE mode:

(...)
14:11:06     20180  [TRACE]  Web > About to run from app.doScript the following VBScript:
Dim args : Set args = CreateObject("InDesign.Application").ScriptArgs
			Dim http : Set http = CreateObject("MSXML2.XMLHTTP")
			Dim data : data = 0
			'---
			On Error Resume Next
			http.Open "GET", "https://docs.google.com:443/document/d/1fFt1u5IUhdRDKrzpD7ZiZfEcs5_aopqxBAVm4pyvuhg", False
			http.Send
			'---
			If Err.Number = 0 Then
				args.SetValue "status", CStr(http.StatusText)
				args.SetValue "statusCode", CStr(http.Status)
				args.SetValue "headers", CStr(http.getAllResponseHeaders)
				data = http.responseText
			Else
				args.SetValue "error", CStr(Err.Description)
			End If
			'---
			Set http = Nothing
			Set args = Nothing
			returnValue = data
14:11:07     21338  [WARNG]  Web > [HTTPS] No result from XMLHTTP: Access is denied.

             21340  [WARNG]  ERROR > [Managed] [HTTPS] No result from XMLHTTP: Access is denied.

                             Engine: main - File: /u/indibase/PROD/IDEX/_ISSUES/004_NoResultFromXMLHTTP.jsx - Location: main
                             Stack: [004_NoResultFromXMLHTTP.jsx] :: main()
14:11:12     25929  [TRACE]  $$ > IdExtenso is unloading (KEEP_DORMANT=false)...
             25930  [TRACE]  $$ > Log Calling onUnload().
             25931  [TRACE]  $$ > Env Calling onUnload().
             25932  [TRACE]  $$ > IdExtenso is now unloaded. (Unloading time: 3ms.)
-------  End Logging Stage:  TRACE (25937ms) -------

Investigating…

@grefel Hi Gregor,

Thanks a lot for being here too, your help is greatly appreciated :-)

Choosing the right XMLHTTP object in VB sounds indeed like a crucial problem. I tried to go back to MSXML2.ServerXMLHTTP.6.0 as you suggest, but I then got a “Missing status” error :-(

               104  [TRACE]  $$ > IdExtenso is now loaded. (Loading time: 103ms.)
14:24:19      3618  [TRACE]  Web > About to run from app.doScript the following VBScript:
Dim args : Set args = CreateObject("InDesign.Application").ScriptArgs
			Dim http : Set http = CreateObject("MSXML2.ServerXMLHTTP.6.0")
			Dim data : data = 0
			'---
			On Error Resume Next
			http.Open "GET", "https://docs.google.com:443/document/d/1fFt1u5IUhdRDKrzpD7ZiZfEcs5_aopqxBAVm4pyvuhg", False
			http.Send
			'---
			If Err.Number = 0 Then
				args.SetValue "status", CStr(http.StatusText)
				args.SetValue "statusCode", CStr(http.Status)
				args.SetValue "headers", CStr(http.getAllResponseHeaders)
				data = http.responseText
			Else
				args.SetValue "error", CStr(Err.Description)
			End If
			'---
			Set http = Nothing
			Set args = Nothing
			returnValue = data
14:24:20      4572  [WARNG]  Web > [EXIT] Missing status
              4574  [WARNG]  ERROR > [Managed] [EXIT] Missing status
                             Engine: main - File: /u/indibase/PROD/IDEX/_ISSUES/004_NoResultFromXMLHTTP.jsx - Location: main
                             Stack: [004_NoResultFromXMLHTTP.jsx] :: main()

By contrast, your great restix module always works fine when I test it on my platform with the URL that Charlie submitted. So there is definitely something I do wrong in my VB code, no matter the XMLHTTP object involved here.

Any idea?

@CharlieNH @grefel

The last update of the Web module should solve the present issue. (Please, keep me informed!)

TECHNICAL MEMO

I hope I made some progress in the endemic question of choosing the right XMLHTTP object in VB. (What a nightmare!)

1.

HTTP/2 responses no longer need to feed the StatusText property, so the status message can be empty.

Responses over an HTTP/2 connection will always have the empty byte sequence
as status message as HTTP/2 does not support them.

according to the Fetch Living Standard. See also https://en.wikipedia.org/wiki/HTTP/2#Differences_from_HTTP/1.1.

This caused the “Missing status” message (generated from $$.Web.) So I changed the logic of the routine, which now deals with empty messages by creating an implicit status string based on the statusCode property.

2.

As noted by @grefel, MSXML2.ServerXMLHTTP.6.0 works better in most cases so I've finally abandoned MSXML2.XMLHTTP. This remains a very obscure topic though. My tests have shown that the old lib caused an “Access denied” error just because no user agent was added to the request header!

However, the same issue (or a very similar one) has been reported even with the ServerXMLHTTP version, as shown in the following discussions:

Therefore, for security purposes I've added the line

http.SetRequestHeader "User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; rv:51.0) Gecko/20100101 Firefox/51.0"

in the VB script. This can't hurt… and may solve other “access denied” problems. Interestingly, the old MSXML2.XMLHTTP object resumes normal operation when that fake user agent is declared!

(Could be useful to restix as well, who knows…)

3.

Ultimately, I still can't decide whether ServerXMLHTTP wins the game against XMLHTTP in all environments. That's an open question to me, and to other programmers. Maybe MSXML2.XMLHTTP.6.0 would be a better choice… I don't know.

Thanks for the detailed investigation. Indeed I use a faked User-Agent String in some projects, I had issues with several servers as well. I thought it would be a good idea not to put the User-Agent String in the library so the user can override it for special cases. But I will think about it.

The last update of the Web module should solve the present issue. (Please, keep me informed!)

Solved on my environment. +1

Solved in my environment, too.

I can't thank both of you enough! This problem was far beyond my capabilities.

One point I'm curious about: it appears that something changed sometime in August, since everything had been working fine until then. I know the change wasn't in my code or in IdExtenso. So from my perspective, it appears that the change had to be in Google's code.

But is that true? Was it actually in "the XMLHTTP object in VB"? Or was it somewhere else? I'm always trying to learn, so any thoughts you could share would be valuable.

Again, thank you very, very much for your many services to the community!

Charlie

@CharlieNH

(…) it appears that something changed sometime in August, since everything had been working fine until then. I know the change wasn't in my code or in IdExtenso. So from my perspective, it appears that the change had to be in Google's code.

But is that true? Was it actually in "the XMLHTTP object in VB"? Or was it somewhere else? I'm always trying to learn, so any thoughts you could share would be valuable.

I wish I could answer that question! But docs.google.com is a Google server and MSXML2 is a Microsoft thing, and these companies are not considered to be very transparent when they change something in their technology… Maybe Google has tightened its identification criteria over https. Maybe Microsoft has added special conditions while invoking the library through VBScript (I suppose this may happen after some Windows Update stage, or any other change related to the security of the system.) The links I posted above show that the whole topic is highly empirical, nobody seems to know the actual cause of these connection issues. As often in that field, people have tricks or hacks that just work, but no serious explanation :-(

Thanks anyway for your feedback. Very useful for documenting technical oddities …and improving the framework :-)