HTTP Get and Timeout

498 views
Skip to first unread message

Frederick Giasson

unread,
Jan 22, 2011, 6:00:29 PM1/22/11
to Tasker
Hi Everybody,

First, it is my first day with Tasker, and I searched this forum for
an answer (without any success).

I am trying to figure out how to check if a server is alive or not. I
thought about simply using the HTTP Get action, then set a timeout,
and then if it time out, then sending an alert. Cannot be simpler than
that. However, it seems that there is no way to "catch" the timeout
error sent by Tasker (like creating a signal event with a IF condition
that says: if timeout (or and error happened), then send the signal.
However, there is no variable for this.

Also, it seems that if an error occurs in HTTP Get, then it stops the
execution to the subsequent actions (if it wouldn't, I could have
estimated the running time of the action with the Task Queue Seconds
variable, and guessed that a timeout occurred. However, it doesn't
seem possible.

Any advices?

Thanks!

Take care,

Fred

Pent

unread,
Jan 23, 2011, 4:01:10 AM1/23/11
to Tasker
> I am trying to figure out how to check if a server is alive or not. I
> thought about simply using the HTTP Get action, then set a timeout,
> and then if it time out, then sending an alert. Cannot be simpler than
> that. However, it seems that there is no way to "catch" the timeout
> error sent by Tasker (like creating a signal event with a IF condition
> that says: if timeout (or and error happened), then send the signal.
> However, there is no variable for this.
>
> Also, it seems that if an error occurs in HTTP Get, then it stops the
> execution to the subsequent actions (if it wouldn't, I could have
> estimated the running time of the action with the Task Queue Seconds
> variable, and guessed that a timeout occurred. However, it doesn't
> seem possible.

You could make a test task like this:

Variable Clear, %PINGOK
HTTP Get
Variable Set, %PINGOK, 1 [ If %HTTPR = 400 ]

Then when you want to test connectivity:

Perform Task, TestTask
Flash "OK!" [If Is Set %PINGOK ]

Make sure the priority of TestTask that you set is higher than that of
the calling task.

Pent

Frederick Giasson

unread,
Jan 23, 2011, 9:52:52 AM1/23/11
to Tasker
Hi Pent!

> You could make a test task like this:
>
> Variable Clear, %PINGOK
> HTTP Get
> Variable Set, %PINGOK, 1 [ If %HTTPR = 400 ]
>
> Then when you want to test connectivity:
>
> Perform Task, TestTask
> Flash "OK!" [If Is Set %PINGOK ]
>
> Make sure the priority of TestTask that you set is higher than that of
> the calling task.

Thanks for taking time to answer that quickly!

This will work if the server returns 400. However maybe I didn't use
the good term, instead of "alive" let's talk about "responsive". So, I
want to check if the server answer to the HTTP GET request *before*
that Tasker reach the timeout I set.

I tested multiple things yesterday, but I didn't find the good profile
to create.

The problem is that cannot see how (if I can) detect if the task
reached the timeout or not. If there some internal/undocumented
variables that get set when an error (exception) is returned by
Tasker?

Otherwise, as I said above, I tried to check the "running time" of the
called task (TestTask in your example above) using the %QTIME
variable, but for some reason, it didn't work at all




So, I check with a simpler version of yours, just to make sure that
the next actions of the tasks that call TestTask was working. So I did
this:


-------
(CallingTask) [Priority = 5]
Perform Task, TestTask [Stop Is Set] [Priority = 7]
Flash "OK!"

(TestTask)
HTTP Get [Timeout = 5]
-------

My problem here is that "Flash "OK!" is never triggered. I was
expecting it to get triggered after the timeout of TestTask... however
I just get the IO error from the HTTP Get action, and nothing else :|

This may tell you what I do wrong!


Finally, may I suggest a message update? When you create a task, and
then create another task that call that newly created task, then the
user gets the message "task not existing" or something similar. I
would suggest to change it for something thing: "task not existing:
make sure you applyed new tasks". Just to make sure that the user know
that he has to apply all changes to tasker in order to have access to
it :)


Thanks for your help!


Take care,


Fred
Reply all
Reply to author
Forward
0 new messages