HTTPClient Timeout Just delays the connection execution

You must Login before you can answer or comment on any questions.

I have been using the Ti.Network.HTTPClinet in an iPhone app and it seems that when I use setTimeout(5000) it will delay the post from hitting the server for 5 seconds. Is this how the timeout should be working? It seems to be more of a delay then a timeout setting.

Thanks

2 Answers

Thomas

Yes, setTimeout executes a code snippet or a function after specified delay. Hence, what you are observing is expected behaviour.

I think what you are really looking for is setInterval:

setInterval takes 2 arguments: function and timeout in milliseconds
for how often the function should be executed until cancelled and
returns a timer handle that can be used to cancel a timer with
clearInterval.
See Titanium's built-in timers for this extract.

— answered 3 years ago by Paul Dowsett
answer permalink
2 Comments
  • Thanks for the response Hal. I understand the setTimeout / setIntraval functions. I am actually referring to the HTTPClient setTimeout as outlined in the Mobile API Docs.

    — commented 3 years ago by Thomas Wheeler

  • Oh, I stand corrected, Thomas. :) In that case, it does indeed seem strange behaviour, and I cannot imagine the reason. I agree with you, I too would expect it to wait for a response within 5 seconds, and cancel the request when the period ends. Hopefully someone will chime in with an explanation.

    — commented 3 years ago by Paul Dowsett

Thanks for the response Hal. I understand the setTimeout / setIntraval functions. I am actually referring to the HTTPClient setTimeout as outlined in the Mobile API Docs.

— answered 3 years ago by Thomas Wheeler
answer permalink
1 Comment
  • Oh, I stand corrected, Thomas. :) In that case, it does indeed seem strange behaviour, and I cannot imagine the reason. I agree with you, I too would expect it to wait for a response within 5 seconds, and cancel the request when the period ends. Hopefully someone will chime in with an explanation.

    — commented 3 years ago by Paul Dowsett

Your Answer

Think you can help? Login to answer this question!