Download MetaTrader 5

WebRequest always return code -1

To add comments, please log in or register
nchankov
15
nchankov  

Hi guys,

I am facing wired problem when I am trying to use WebRequest() function on Windows.


Here is the simplest code which could be written:

void OnStart()
{
   string url = "http://server.com";
   string headers = "application/json";
   int timeout = 5000;
   char post[],result[];
   string result_header;
   int res;
   
   string message = "this is a test";
   StringToCharArray(message,post,0,StringLen(message));
   res=WebRequest("POST", url, headers, timeout, post, result, result_header);
   Print(res);
   if (res == -1) {
      Print("Error in WebRequest. Error code  =",GetLastError());
   }
}

Of course I've added the https://google.com to options->ExpertAdvisors tab.

I am running Wine on Ubuntu on which I am running the Metatrader4. On this instance I got res=200 which is quite ok


The problem is when I try to install the following Script on a Windows 8.1. On that Windows I have internet access (I can load any page from a browser) and of course the address is in the options->expert advisors

MetaTraders are the same versions, but when I install it and run it, I always got res=-1 and the last error is 5203.


Is it possible WebRequest to require some permissions from Windows, or is it using something like Curl-like app which is missing and it couldn't execute the web request, or even some Service Pack which is not installed? I am more linux than Windows user and I didn't install that Windows (it's a friend of mine), so not sure if everything is correctly there.

Also I tried to install Metatrader on a VirtualMachine (VirtualBox) Win8.1 and I got the same error, so it let me think it could be some Windows related.


Does anyone experienced the same problem?

Any help is much appreciated

Goutagny Philippe
157
Goutagny Philippe  
nchankov:

Hi guys,

I am facing wired problem when I am trying to use WebRequest() function on Windows.


Here is the simplest code which could be written:

Of course I've added the https://google.com to options->ExpertAdvisors tab.

I am running Wine on Ubuntu on which I am running the Metatrader4. On this instance I got res=200 which is quite ok


The problem is when I try to install the following Script on a Windows 8.1. On that Windows I have internet access (I can load any page from a browser) and of course the address is in the options->expert advisors

MetaTraders are the same versions, but when I install it and run it, I always got res=-1 and the last error is 5203.


Is it possible WebRequest to require some permissions from Windows, or is it using something like Curl-like app which is missing and it couldn't execute the web request, or even some Service Pack which is not installed? I am more linux than Windows user and I didn't install that Windows (it's a friend of mine), so not sure if everything is correctly there.

Also I tried to install Metatrader on a VirtualMachine (VirtualBox) Win8.1 and I got the same error, so it let me think it could be some Windows related.


Does anyone experienced the same problem?

Any help is much appreciated


you spoke about google.com but string url = "http://server.com"; ???

nchankov
15
nchankov  

Well, both were used as example. I wrote google, then switched the code to server.com as to show it's any server.

I came to the conclusion that it's an issue with the Windows, but I can't find any resource pointing to a solution or what cause it

Goutagny Philippe
157
Goutagny Philippe  
nchankov:

Well, both were used as example. I wrote google, then switched the code to server.com as to show it's any server.

I came to the conclusion that it's an issue with the Windows, but I can't find any resource pointing to a solution or what cause it


did you try all different headers : I face another problem with webrequest and the solution was headers :

string headers = "User-Agent: Mozilla/4.0\r\n"; or "User-Agent: Mozilla/5.0\r\n";  there's plenty of possibility !

To add comments, please log in or register