Webrequest timeout ignored

 
Does anyone know why timeout whrn performing a webrequest is ignored? Looking the documentation ti says, timeout in miliseconds. Any value I use, 1000 (1 sec), 2000 or 100000, any value, it is always taken 10 to 12 seconds. Thanks for any input. 
 
magnomilk: Does anyone know why timeout whrn performing a webrequest is ignored? Looking the documentation ti says, timeout in miliseconds. Any value I use, 1000 (1 sec), 2000 or 100000, any value, it is always taken 10 to 12 seconds. Thanks for any input. 

Without more details of what you are doing, it is difficult to say. Maybe the called server is closing the connection itself after a certain delay, or there might be a hard timeout limit built into MetaTrader to prevent the EA/Script thread from freezing, but I am just speculating here.

 

Hi, @Fernando Carreiro, thanks so much for your reply.

What I am trying to do it is really simple, there is no secret hidden, below the code:

   string headers;
   string result_header;
   char   post[],result[];
   urlExtension = "/logins/ping";
   int timeout=1000;
   string completeURL = protocol + url + urlExtension;   
   int res=WebRequest("GET",completeURL,headers,timeout,post,result,result_header);   // it holds here up to 10 to 12 secs...
   if(res==-1){
//if this happens I know that I have to add the server url to the metatrade white list.
   }


You can observe that the timeout is set to 1000. So, if the server doens't reply in 1 second I want to continue, it get stuck up to 10 to 12 seconds everytime, and with any timeout value, even bigger than 20000.

Thanks for any input.

 
Fernando Carreiro #:

Without more details of what you are doing, it is difficult to say. Maybe the called server is closing the connection itself after a certain delay, or there might be a hard timeout limit built into MetaTrader to prevent the EA/Script thread from freezing, but I am just speculating here.


Any idea, after my explanation? Thanks for any input.

 
magnomilk #: Any idea, after my explanation? Thanks for any input.

In your original post, the website itself suggested a related thread about the your topic. Did you read it? It seems to be very relevant to your question.

 
Fernando Carreiro #:

In your original post, the website itself suggested a related thread about the your topic. Did you read it? It seems to be very relevant to your question.

Thanks... I have checked this topic before, the question is similar to mine, but the answer doesn't match, it doesn't solve it.

Again, I perform a webRequest and would like to have a timeout to set to 1 second. In MQL5 EA it always times out after 10 seconds, regardless the configuration.

Kindly help me with it. Very important to solve it, I have tried everything...

Best Regards

Magno Leite

 
magnomilk #:

Thanks... I have checked this topic before, the question is similar to mine, but the answer doesn't match, it doesn't solve it.

Again, I perform a webRequest and would like to have a timeout to set to 1 second. In MQL5 EA it always times out after 10 seconds, regardless the configuration.

Kindly help me with it. Very important to solve it, I have tried everything...

Best Regards

Magno Leite

Some questions/remarks.

1. Is it 10 seconds or 10 to 12 seconds as you reported previously ?

2. What is the value of "res" ? Sometimes res is a value >=1000 (which means an error but -1 is not returned because it indicates an internal error number), so you need to check the value of _LastError.

3. Please post a log output which demonstrate your issue.

4. Is your URL public so we could test it ourself ? If yes please send me a simple code and the URL to test it (in private if your prefer). Then I will check and ask MQ an explanation if it's confirmed.

 
Alain Verleyen #:

Some questions/remarks.

1. Is it 10 seconds or 10 to 12 seconds as you reported previously ?

2. What is the value of "res" ? Sometimes res is a value >=1000 (which means an error but -1 is not returned because it indicates an internal error number), so you need to check the value of _LastError.

3. Please post a log output which demonstrate your issue.

4. Is your URL public so we could test it ourself ? If yes please send me a simple code and the URL to test it (in private if your prefer). Then I will check and ask MQ an explanation if it's confirmed.

First of all thanks so much for the quick reply. As I said it is really urgent. Very appreciate.

In fact it is taking 14 to 15 seconds for me to receive a timeout.

The res is 5203.

I have prepared a test server for this purpose. I will send a private message with all the details and code if I am allowed to.

In a nutshell it is: I have a server listening on port 444, when the nodejs server is up, my MQL5 code receives the response in milisencond. If I stop the server that is listening on port 444, the MQL5 code hangs for 15 seconds. I will keep the 444 running, I believe you can simulate it changing the port number to 445on MQL5 code (no application listening on it).

Thanks in advance

Magno Leite

 
magnomilk #:

First of all thanks so much for the quick reply. As I said it is really urgent. Very appreciate.

In fact it is taking 14 to 15 seconds for me to receive a timeout.

The res is 5203.

I have prepared a test server for this purpose. I will send a private message with all the details and code if I am allowed to.

In a nutshell it is: I have a server listening on port 444, when the nodejs server is up, my MQL5 code receives the response in milisencond. If I stop the server that is listening on port 444, the MQL5 code hangs for 15 seconds. I will keep the 444 running, I believe you can simulate it changing the port number to 445 on MQL5 code (no application listening on it).

Thanks in advance

Magno Leite

@Alain Verleyen  I have sent a message to you (think it was a private message). Thanks in advance.

 

So, does this issue have solution?

I have an error 5203 as well.

Request timeout not working

 
taras.k #:

So, does this issue have solution?

I have an error 5203 as well.

Request timeout not working

It was transmitted to MetaQuotes but I never had an answer.