You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@pivot.apache.org by Bill van Melle <bi...@gmail.com> on 2011/02/01 02:31:37 UTC

GetQuery doesn't return over sleep (MacOS)

I'm having an issue where I call GetQuery.execute, but neither
the taskExecuted nor the executeFailed methods of my TaskListener are being
called.  Should this ever happen?  It happens for me if the Mac sleeps while
the call is in progress.  There is also some other condition that does it
that I haven't quite been able to nail down.

(More info: the GetQuery is a "long poll" to a server that doesn't return
until new information is available (or a timeout passes).  When the call
returns, my program processes the result, and issues another query.
 Naturally, if the call never returns, the program stops updating -- not
good.  I'd hate to have to add logic that detects this condition and
restarts the long poll cycle.)

Re: GetQuery doesn't return over sleep (MacOS)

Posted by Chris Bartlett <cb...@gmail.com>.
Bill,

Good to hear that you found a workaround so quickly.

Adding configurable timeouts to relevant org.apache.pivot.web &
org.apache.pivot.web.server classes sounds like a valid feature request.

Chris

On 2 February 2011 05:57, Bill van Melle <bi...@gmail.com> wrote:

> I was able to reproduce the issue using very simple calls via java.net.URL.
>  And it's not specific to sleeping.  Unplugging your network cable does the
> same thing.
>
> As best I can tell, the problem is that the connection timeout on the Mac
> is infinite, whereas on Windows it's a reasonable finite number (maybe 2
> minutes)?  So in my test case with java.net.URL, I can avoid the issue by
> setting the connection timeout:
>
>     URL url = new URL(...);
>     HttpURLConnection conn = (HttpURLConnection) url.openConnection();
>     conn.setConnectTimeout(timeoutMs);
>     conn.setReadTimeout(timeoutMs);
>     conn.connect();
>     . . .
>
> I don't see how I can do this with GetQuery.  There is a setTimeout method
> in Task, but it's not exactly the same notion ("The time by which the task
> must complete execution"), and GetQuery doesn't seem to pay attention to it
> anyway ("It is the responsibility of the implementing class to respect this
> value.")
>

Re: GetQuery doesn't return over sleep (MacOS)

Posted by Bill van Melle <bi...@gmail.com>.
I was able to reproduce the issue using very simple calls via java.net.URL.
 And it's not specific to sleeping.  Unplugging your network cable does the
same thing.

As best I can tell, the problem is that the connection timeout on the Mac is
infinite, whereas on Windows it's a reasonable finite number (maybe 2
minutes)?  So in my test case with java.net.URL, I can avoid the issue by
setting the connection timeout:

    URL url = new URL(...);
    HttpURLConnection conn = (HttpURLConnection) url.openConnection();
    conn.setConnectTimeout(timeoutMs);
    conn.setReadTimeout(timeoutMs);
    conn.connect();
    . . .

I don't see how I can do this with GetQuery.  There is a setTimeout method
in Task, but it's not exactly the same notion ("The time by which the task
must complete execution"), and GetQuery doesn't seem to pay attention to it
anyway ("It is the responsibility of the implementing class to respect this
value.")

Re: GetQuery doesn't return over sleep (MacOS)

Posted by Chris Bartlett <cb...@gmail.com>.
Bill,

Yeah, I was also wondering the best way to deal with that side of things.
 Can you reproduce the issue on any public accessible webservices?  If not,
a Tomcat servlet should suffice.

Perhaps it would be simpler if first you could try to see if a non-Pivot
version fails in the same way?  If it doesn't then it suggests that the
problem is in the Pivot codebase and not just to do with Java's (or the
OS's) handling of power states.  I was thinking of something along the lines
of making the connection to your existing web service, putting your Mac into
a sleep state, waking it up and checking the connection again.  Creating an
example for JIRA may involve more effort.

I would like to be able to rule out (or in) a few things one way or another.

Things like
- does this just occur with Pivots web classes or with the underlying Java
ones too
- is the problem on the client side or the server side (or in the middle if
a proxy is used)
- does the duration of the sleep matter and does it also occur with
hibernation (Do Macs hibernate?)

As I mentioned, I am not familiar with the org.apache.pivot.web package, or
these java.net methods for that matter!  So don't hesitate to point out if I
am suggesting something stupid or that would take a great deal of effort on
your part   :)

Chris

On 2 February 2011 02:21, Bill van Melle <bi...@gmail.com> wrote:

> Okay, I'll run some experiments and get back to you.  Of course, making a
> reproducible example requires a long-poll-style web service somewhere.  I
> could make a trivial Tomcat servlet, or a standalone Python server, or
> something like that to include.  What's suitable?

Re: GetQuery doesn't return over sleep (MacOS)

Posted by Bill van Melle <bi...@gmail.com>.
Okay, I'll run some experiments and get back to you.  Of course, making a
reproducible example requires a long-poll-style web service somewhere.  I
could make a trivial Tomcat servlet, or a standalone Python server, or
something like that to include.  What's suitable?

Re: GetQuery doesn't return over sleep (MacOS)

Posted by Chris Bartlett <cb...@gmail.com>.
Bill,

I think we will need some more input from you in order to investigate this.

Could you please create a JIRA ticket, preferably with a minimal example
application attached and the steps to reproduce the behaviour?
https://issues.apache.org/jira/browse/PIVOT

I haven't used the org.apache.pivot.web package myself, but it looks like
wrappers for java.net.URL & java.net.HttpURLConnection.  If you take Pivot
out of the picture and use those directly, do you still see the issue?

Chris

On 1 February 2011 08:31, Bill van Melle <bi...@gmail.com> wrote:

> I'm having an issue where I call GetQuery.execute, but neither
> the taskExecuted nor the executeFailed methods of my TaskListener are being
> called.  Should this ever happen?  It happens for me if the Mac sleeps while
> the call is in progress.  There is also some other condition that does it
> that I haven't quite been able to nail down.
>
> (More info: the GetQuery is a "long poll" to a server that doesn't return
> until new information is available (or a timeout passes).  When the call
> returns, my program processes the result, and issues another query.
>  Naturally, if the call never returns, the program stops updating -- not
> good.  I'd hate to have to add logic that detects this condition and
> restarts the long poll cycle.)
>
>
>
>