Page 1 of 1 1
Topic Options
#185073 - 2008-02-05 01:16 AM http response timeout?
brewdude6 Offline
Hey THIS is FUN

Registered: 2000-10-21
Posts: 280
Loc: Nashville, TN
I need to set a 20 second timeout on an http request. I found some documentation in vb on SetTimeout, but I'm having no luck in kix. This is what I have so far. The script works fine without the "settimeout" bit that I added. Any help would be appreciated.

 Code:
  $objhttp = CreateObject("Microsoft.XMLHTTP")
  $timeout=20000
  $objhttp.setTimouts($timeout,$timeout,$timeout,$timeout)
  $objhttp.Open("GET", $url, Not)
  $objhttp.Send
  $Status=($objhttp.ResponseText)
  If Not InStr($Status, $string)
  Do something
  else
  do something else
  endif
_________________________
I could have made a neat retort but didn't, for I was flurried and didn't think of it till I was downstairs.
-Mark Twain

Top
#185074 - 2008-02-05 02:00 AM Re: http response timeout? [Re: brewdude6]
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11631
Loc: CA
Well timeouts are not really supported, but you might be able to do something with this

MSXML2.XMLHTTP with a TimeOut Value

Top
#185088 - 2008-02-05 04:44 PM Re: http response timeout? [Re: brewdude6]
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
Did you really mean "setTimouts" or is that a typo?

I would have expected setTimeeouts

Top
#185090 - 2008-02-05 04:48 PM Re: http response timeout? [Re: Richard H.]
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
There are two e in your response Richard
_________________________



Top
#185094 - 2008-02-05 05:43 PM Re: http response timeout? [Re: Jochen]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4402
Loc: New Jersey
I think he was making up for the earlier missing "e". Now the post is at least balanced! ;\)

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#185101 - 2008-02-06 03:36 AM Re: http response timeout? [Re: Richard H.]
brewdude6 Offline
Hey THIS is FUN

Registered: 2000-10-21
Posts: 280
Loc: Nashville, TN
Yes..that was a typo.

Can I check readystate like this for a response timeout?

 Code:
  $objhttp.Send
  Sleep 10
  If $objhttp.readyState <> 4
_________________________
I could have made a neat retort but didn't, for I was flurried and didn't think of it till I was downstairs.
-Mark Twain

Top
#185102 - 2008-02-06 07:19 AM Re: http response timeout? [Re: brewdude6]
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Looks fishy...

better?

 Code:
$objhttp.Send
while $objhttp.readyState <> 4 | $sleepy<10
    $sleepy=0.01+$sleepy
    sleep 0.01
loop
If $objhttp.readyState <> 4 


This is of course no statement for the value of the readyState property, as I simply don't know what it means. I posted just to show you a way to get rid of 10 boring seconds where the users asks himself if the script hangs ;\)


Edited by Jochen (2008-02-06 07:20 AM)
Edit Reason: Gawd, the english grammar is awesome
_________________________



Top
#185104 - 2008-02-06 09:15 AM Re: http response timeout? [Re: Jochen]
brewdude6 Offline
Hey THIS is FUN

Registered: 2000-10-21
Posts: 280
Loc: Nashville, TN
Thanks Jochen, here's some info on readystate...if you care.

readyState Property Values
0 The object has been created but has not been initialized because open method has not been called.
1 The object has been created but the send method has not been called.
2 The send method has been called and the status and headers are available, but the response is not yet available.
3 Some data has been received. You can call responseBody and responseText to get the current partial results.
4 All the data has been received, and the complete data is available in responseBody and responseText.
_________________________
I could have made a neat retort but didn't, for I was flurried and didn't think of it till I was downstairs.
-Mark Twain

Top
#185105 - 2008-02-06 09:15 AM Re: http response timeout? [Re: Jochen]
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
 Quote:
I posted just to show you a way to get rid of 10 boring seconds where the users asks himself if the script hangs


Ahh... you don't lose the wait.

That "|" in your conditional will always evaluate true while $sleepy is less than 10:
 Code:
while $objhttp.readyState <> 4 | $sleepy<10


A small nip 'n' tuck should sort that out:
 Code:
while $objhttp.readyState <> 4 AND $sleepy<10


Riposte!

Top
#185116 - 2008-02-06 08:51 PM Re: http response timeout? [Re: Richard H.]
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Arrrgh! Touché

This is what you get for posting untested code cobbled together before the first coffee in the morning.

I meant of course & and not | (wow, 4 KiX keywords in a row )

Yo brewdude, will keep this post in mind (or better in my watchlist) for later reference!



Edit again: While testing this I think I found an interesting bug ... we'll see


Edited by Jochen (2008-02-06 09:20 PM)
_________________________



Top
Page 1 of 1 1


Moderator:  Shawn, ShaneEP, Ruud van Velsen, Arend_, Jochen, Radimus, Glenn Barnas, Allen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 837 anonymous users online.
Newest Members
ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder, M_Moore
17887 Registered Users

Generated in 0.094 seconds in which 0.024 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org