Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HeartbeatInterceptor executed before IdleResourceInterceptor #1760

Closed
freongrr opened this issue Nov 5, 2014 · 12 comments
Closed

HeartbeatInterceptor executed before IdleResourceInterceptor #1760

freongrr opened this issue Nov 5, 2014 · 12 comments

Comments

@freongrr
Copy link

freongrr commented Nov 5, 2014

I'm using client heartbeats, but IdleResourceInterceptor keeps cancelling my resources.

It turns out that IdleResourceInterceptor#inspect() is never called (and the "MAX_INACTIVE" property is never updated), because HeartbeatInterceptor is invoked first, and it cancels the request from the client.

How about bumping up IdleResourceInterceptor in the list of default interceptors in AtmosphereFramework?

For reference, this is my handler definition:

    @ManagedService(
      path = "/push",
      interceptors = {
        AtmosphereResourceLifecycleInterceptor.class,
        TrackMessageSizeInterceptor.class,
        SuspendTrackerInterceptor.class,
        GwtRpcInterceptor.class,
        AtmosphereMessageInterceptor.class,
      },
      atmosphereConfig = {
        "org.atmosphere.interceptor.HeartbeatInterceptor.clientHeartbeatFrequencyInSeconds=60",
        "org.atmosphere.cpr.CometSupport.maxInactiveActivity=180000"
      }
    )
    public class TestPushManager {
      ...
    }

And this is the order of interceptors when I hit AsynchronousProcessor#action():

  • UUID Tracking Interceptor
  • Track Message Size Interceptor using |
  • CORS Interceptor Support
  • Default Response's Headers Interceptor
  • Browser Padding Interceptor Support
  • Android Interceptor Support
  • Heartbeat Interceptor Support
  • SSE Interceptor Support
  • JSONP Interceptor Support
  • Atmosphere JavaScript Protocol
  • org.atmosphere.interceptor.WebSocketMessageSuspendInterceptor
  • Browser disconnection detection
  • org.atmosphere.interceptor.IdleResourceInterceptor
@jfarcand
Copy link
Member

jfarcand commented Nov 5, 2014

@freongrr It really depends on how you see it, IdleResourceInterceptor means there is no real byte sent on the wire. That exclude heartbeat bytes ... if I change the framework the way you are asking for, that means IdleResourceInterceptor will be useless in that case. So not sure...

@nicolasllk
Copy link

I am having the same issue. What jfarcand says is logical but is there any way to achieve this without tampering with the framework?

@freongrr
Copy link
Author

freongrr commented Nov 5, 2014

In my case, I update the MAX_INACTIVE attribute on the resource in my onHeartbeat() method.

But then, shouldn't HeartbeatInterceptor do that?

@nicolasllk
Copy link

In either case, shouldn't heartbeat lunch an exception when sending data through a closed connection?

@jfarcand
Copy link
Member

jfarcand commented Nov 6, 2014

@nicolasllk Lunch an exception to where? If you turn the log to trace, you will see the exeption.

@jfarcand
Copy link
Member

@freongrr If you make the change in the code by moving the interceptor, does it help? If yes, pull request welcomed :-)

@freongrr
Copy link
Author

Yes, the change is easy. I'll have to keep it running for a while to see how it works.

@jfarcand
Copy link
Member

jfarcand commented Jan 8, 2015

@freongrr Any update?

@freongrr
Copy link
Author

freongrr commented Jan 9, 2015

So, I could not test because the load balancer my company uses drops some websocket messages...

@jfarcand jfarcand added the 2.3.0 label Feb 25, 2015
@jfarcand
Copy link
Member

@freongrr Any feedback? I'm tempted to switch the order, but I first want feedback from you.

@freongrr
Copy link
Author

As I said above, I had to stop using websockets. The change worked during my limited testing, but I could not see how it worked in a real deployment.

@jfarcand
Copy link
Member

With #1877 , IdleResourceInterceptor will always be executed first. Closing as fixed, but in case you have time, please test :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants