cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Adam Boyle <>
Subject ROP: detecting that my client connection has timed out
Date Fri, 08 Apr 2016 03:28:31 GMT
I have a rich client application that uses the Apache Cayenne Remote Object Persistence framework
to access and store data. Thus far I have been unable to find a graceful way of detecting
and handling a client connection timeout. A MissingSessionException is thrown on both the
client and server when an action is attempted after the session has timed out, but on the
client side this exception is caught and a stacktrace is printed to the console without propagating
out to the caller:

    Apr 07, 2016 2:48:48 PM org.apache.cayenne.remote.BaseConnection sendMessage
    INFO: --- Message 6: Query
    Apr 07, 2016 2:48:48 PM org.apache.cayenne.remote.BaseConnection sendMessage
    INFO: *** Message error for 6: Query - took 16 ms.
    org.apache.cayenne.remote.service.MissingSessionException: [v.4.0.M2 Feb 26 2015 08:16:32]
[v.4.0.M2 Feb 26 2015 08:16:32] No session associated with request.
        at org.apache.cayenne.remote.service.BaseRemoteService.processMessage(
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(
        at java.lang.reflect.Method.invoke(
        at com.caucho.hessian.server.HessianSkeleton.invoke(
        at com.caucho.hessian.server.HessianSkeleton.invoke(
        at com.caucho.hessian.server.HessianServlet.service(
        at org.eclipse.jetty.servlet.ServletHolder.handle(
        at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(
        at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(
        at org.apache.shiro.web.servlet.AdviceFilter.executeChain(
        at org.apache.shiro.web.servlet.AdviceFilter.doFilterInternal(
        at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(
        at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(
        at org.apache.shiro.web.servlet.AbstractShiroFilter.executeChain(
        at org.apache.shiro.web.servlet.AbstractShiroFilter$
        at org.apache.shiro.web.servlet.AbstractShiroFilter.doFilterInternal(
        at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(
        at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(
        at org.eclipse.jetty.servlet.ServletHandler.doHandle(
        at org.eclipse.jetty.server.handler.ScopedHandler.handle(
        at org.eclipse.jetty.server.session.SessionHandler.doHandle(
        at org.eclipse.jetty.server.handler.ContextHandler.doHandle(
        at org.eclipse.jetty.servlet.ServletHandler.doScope(
        at org.eclipse.jetty.server.session.SessionHandler.doScope(
        at org.eclipse.jetty.server.handler.ContextHandler.doScope(
        at org.eclipse.jetty.server.handler.ScopedHandler.handle(
        at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(
        at org.eclipse.jetty.server.handler.HandlerCollection.handle(
        at org.eclipse.jetty.server.handler.HandlerWrapper.handle(
        at org.eclipse.jetty.server.Server.handle(
        at org.eclipse.jetty.server.HttpChannel.handle(
        at org.eclipse.jetty.server.HttpConnection.onFillable(
        at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(
        at org.eclipse.jetty.util.thread.QueuedThreadPool$

Is there a simple way of detecting that the connection is dead so that I can prompt the user
to reconnect?

On a related note, what happens to the existing client ObjectContext objects that are in use
if the connection is able to be re-established? Are the uncommitted PersistentObjects previously
created in those contexts lost forever?

The only (hacky) solution I can think of is to actually run a keep-alive thread to periodically
send a low-latency query to Cayenne to keep the ROP session active and separately track application
activity and prompt the user to enter their password if a certain period of time has passed
with no activity. The problem that I see with an approach like that is that there are lots
of ways that activity could be missed, the application is not truly timing out, and it really
doesn't address the underlying problem which is that sessions need to time out for a reason
and there doesn't seem to be a way to detect such a timeout.

Thanks in advance for any help you can provide!

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message