Timeout ignored in WebRequest calls

 

Hello, I need to use WebRequest to access some online information but I don't want my EA to get stuck waiting the server's response. Here is a simple script I was using to test the timeout input in the WebRequest function.

void OnStart()
{
   string       url = "https://httpstat.us/200?sleep=15000";
   string       cookie = NULL;
   string       referer = NULL;
   int          timeout = 100; //timeout in milliseconds
   char         data[];
   int          data_size = ArraySize(data);
   char         result[];
   string       result_headers;

   ResetLastError();
   uint start = GetTickCount();
   int res = WebRequest( "GET", url, cookie, referer, timeout, data, data_size, result, result_headers);
   uint delay = GetTickCount() - start;
   
   switch( res )
   {
        case -1: 
                        PrintFormat("Error in WebRequest. Error code = %d",GetLastError());
                        MessageBox("Add the address '"+url+"' to the list of allowed URLs on tab 'Expert Advisors'","Error",MB_ICONINFORMATION);
                        break;
        case 200:
                        PrintFormat("Content: %s", CharArrayToString( result, 0, WHOLE_ARRAY ) );
                        PrintFormat("Delay: %f", delay);
                        PrintFormat("Hearders: %s", result_headers );
                        break;
        default:
                        PrintFormat("Response code %d",res);
                        break;
   };
}

But no matter what value (-1, 0, 500 and so on) I use for timeout, the call always waits the server's response. I am currently using MQL5 on Version 5.0 Build 3550, and the problem also seems to occur in both WebRequest overloads that appear in the documentation. It also doesn't seem to matter if you run the code above on a Script or an EA.

Here is the result produced:

Files:
timeout.png  8 kb