URLDownloadToFileW doesn’t work on VPS

 

perhaps you can help, the following function usage works properly on my local pc but fails on my vps:

#import “urlmon.dll”

int URLDownloadToFileW(int pCaller,string szURL,string szFileName,int dwReserved,int Callback);

#import

I am trying to use it to read a price and display it as part of an Metatrader 4 indicator. Any idea what could be the server issue?

 
Roy Meshulam: but fails on my vps:
Most VPS do not allow DLL calls. Does yours?
 
William Roeder:
Most VPS do not allow DLL calls. Does yours?
How can i check it?
 

How should I know what VPS you are using? There are no mind readers here and our crystal balls are cracked. Perhaps you could read your VPS documentation.

 
William Roeder:

How should I know what VPS you are using? There are no mind readers here and our crystal balls are cracked. Perhaps you could read your VPS documentation.

I am using windows server 2012 r2
 
William Roeder:

How should I know what VPS you are using? There are no mind readers here and our crystal balls are cracked. Perhaps you could read your VPS documentation.

William, usually I like your sarcasm, but here it was a bit too much.


For example, my VPS allows DLL calls and I do not know why or what is this "VPS documentation" which you are referring to.

This is not a known term, and you may refer to the Terms and Conditions of the host company.

I would also like to know how we can differ from one VPS to another regarding this DLL issue.

 

1. I have found this solution (untested):

https://stackoverflow.com/questions/34923409/excel-vba-urldownloadtofile-error-for-httpsresource

It refers to VBA, but if you can translate the required step to MQL4 and connect with WinHTTP (https://docs.microsoft.com/en-us/windows/win32/winhttp/winhttp-start-page?redirectedfrom=MSDN), it would probably be great.


2. Try performing the steps listed here:

https://social.msdn.microsoft.com/Forums/ie/en-US/4e39a225-3745-4e2f-bd91-c6fd725d4de4/urldownloadtofile-not-working-in-windows-7-with-https?forum=ieextensiondevelopment


3. You can also download external tool which is called "cURL", or "curl", and then run in shell:

#import "shell32.dll"

int ShellExecuteW(int hwnd,string Operation,string File,string Parameters,string Directory,int ShowCmd);

#import


Then when you want to run it you do it this way:

ShellExecuteW(0, "Open", "curl.exe --url http://Your_URL.com >yourfilename.txt", "", "", 1);

 
Roy Meshulam:

perhaps you can help, the following function usage works properly on my local pc but fails on my vps:

#import “urlmon.dll”

int URLDownloadToFileW(int pCaller,string szURL,string szFileName,int dwReserved,int Callback);

#import

I am trying to use it to read a price and display it as part of an Metatrader 4 indicator. Any idea what could be the server issue?

Fails how ? That's what you should have said.

Most probably the code runs (so it's not a DLL issue) but URLDownloadToFileW() returns a INET_E_DOWNLOAD_FAILURE code. That's due to Internet Explorer Enhanced Security  which is enabled on your server. Open your url with Internet Explorer to check and eventually add it to the Trusted Sites.

 
Tom Sasson: William, usually I like your sarcasm, but here it was a bit too much.

For example, my VPS allows DLL calls and I do not know why or what is this "VPS documentation" which you are referring to.

This is not a known term, and you may refer to the Terms and Conditions of the host company.

I would also like to know how we can differ from one VPS to another regarding this DLL issue.

  1. You expect someone to answer your vague question with no information? All you said was:
    Roy Meshulam: but fails on my vps:
  2. You know it allows DLL calls? Are you a mind reader? Do you have a working crystal ball? You couldn't possibly know that unless you already read the "VPS documentation."
  3. Do you expect someone to know the "Terms and Conditions" from your unknown VPS? We are not mind readers!
  4. "Differ from one to another" isn't even understandable.

The sarcasm is appropriate since you've wasted many people's time (not just mine,) looking at your vague question and not providing any information. I've asked for more twice and yet you've provided nothing.


Tom Sasson:
1. I have found this solution (untested):
2. Try performing the steps listed here:
  1. Good for you. The terminal already has HTTP(s) capability. You just want to complicate things more.
  2. You try performing "the steps". There are no slaves here.

  3. curl.exe --url http://Your_URL.com >yourfilename.txt
    That is bogus executable name. The call is "string File,string Parameters,string Directory."
  4. Is curl in your VPS's path? If not, you are running out of some default directory and you will get "no such file" error, since there will be no curl.exe in that directory.
              Syntax for calling AutoIt compiled Script (.exe) using ShellExecuteW in MT4 EA (Quest) - MQL4 programming forum
              run a *.bat from EA (Route206) - MQL4 programming forum
              Execute an exe-file from MQL (Steffen Siegert) - MQL4 programming forum
  5. Your also trying to redirect output using ">". That is correct syntax, only for the cmd. I doubt you have a URL Your_URL.com%20%3Eyourfilename.txt
 
Alain Verleyen #:

Fails how ? That's what you should have said.

Most probably the code runs (so it's not a DLL issue) but URLDownloadToFileW() returns a INET_E_DOWNLOAD_FAILURE code. That's due to Internet Explorer Enhanced Security  which is enabled on your server. Open your url with Internet Explorer to check and eventually add it to the Trusted Sites.

So much time spent on this error... The function returned me a negative value and I didn't understand why.

when i use IE everytime I moan because of these security settings and I saw in my server that the user-agent was IE for each URLDownloadToFileW request and I didn't make the connection...

Thank you very much Alain. Really.

Regards,

JC