Web request Error 1001

Wayside48
730

I have an EA which regularly reports the status of an account to a web service.  This has worked fine for years on MT4 and I have recently written an MT5 version which has also worked fine for several months on one MT5 account (BlackBull Markets) - and still is!  However I have now put it on another account (ActivTrades) where it works 'occasionally'!  By this I mean that the web requests sometimes send the data ok, but frequently get an HTTP error which is reported as "error 1001".  I can't find any definition of an HTTP code 1001 can anyone help please?  Is this some MQL5 specific code maybe?

For information, here is the web request function and below is a typical error response...

string httpGet(string url)
{
   string cookie = NULL;
   string headers;
   char post[];
   char result[];
   int res;

   //--- Reset the last error code
   ResetLastError();
   
   //--- Timeout below 1000 (1 sec.) is not enough for slow Internet connection
   int timeout = 5000;
   res = WebRequest("GET", url, cookie, NULL, timeout, post, 0, result, headers);

   //--- Checking errors
   if(res == -1)
   {
      writeToLog(StringFormat("Error in WebRequest. Error code = %i, url = %s", GetLastError(), url));
      return "false";
   }
   else if (res == 200)
   {
      // Success, return result as a string...
      return CharArrayToString(result);
   }
   else
   {
      writeToLog(StringFormat("WebRequest to %s failed. Error code = %i", url, res));
      return "false";
   }
}


Alain Verleyen
42598
Wayside48:

I have an EA which regularly reports the status of an account to a web service.  This has worked fine for years on MT4 and I have recently written an MT5 version which has also worked fine for several months on one MT5 account (BlackBull Markets) - and still is!  However I have now put it on another account (ActivTrades) where it works 'occasionally'!  By this I mean that the web requests sometimes send the data ok, but frequently get an HTTP error which is reported as "error 1001".  I can't find any definition of an HTTP code 1001 can anyone help please?  Is this some MQL5 specific code maybe?

For information, here is the web request function and below is a typical error response...


Error 1001 is an internal MQL WebRequest error (I got this information from MQ developer), it means :

1001 - SOCKET_HTTP_NO_CONNECTION

So for some reason your server refuse the connection. Maybe a DDos protection ?

Wayside48
730
Wayside48  
Alain Verleyen #:

Error 1001 is an internal MQL WebRequest error (I got this information from MQ developer), it means :

1001 - SOCKET_HTTP_NO_CONNECTION

So for some reason your server refuse the connection. Maybe a DDos protection ?

Ah, many thanks.  It's odd that some calls get through (and other terminals on the same VPS work fine in this respect) - oh well!

Wayside48
730
Wayside48  
Wayside48 #:

Ah, many thanks.  It's odd that some calls get through (and other terminals on the same VPS work fine in this respect) - oh well!

Rewrote it to use "wininet.dll" instead of the MQL5 web methods and it's now working fine!  Of course it means it can't be used on an MQL5 hosted terminal but I'm not anyway. 

Thanks again Alain.

Ilyas
1646
Ilyas  
You can check result parameter, it may contains additional information about occurred error