DWR

Allow users to set an alternative error handler for polling errors and to specify a retry policy

Details

  • Type: Improvement Improvement
  • Status: Reopened Reopened
  • Priority: Normal Normal
  • Resolution: Unresolved
  • Affects Version/s: None
  • Fix Version/s: 3.0.RC3
  • Component/s: Engine
  • Documentation Required:
    No
  • Description:
    Hide
    In 2.0 pollErrorHandler is not customizable and the retry policy is hard coded. An application may want to be notified when reverse AJAX failed and to specify the number
    of retries and delays between them (e.g. in a clustered environment, we want to retry without a delay a couple of times and then increase the delay).
    I suggest to add an additional user-level error handler, which takes a retry number (in addition to the error message) and returns the next retry delay or -1 to cancel retrying.
    For example, a handler, which implements the current retry policy:

    function(message, ex, retryNum) {
      // if anything goes wrong then just silently try again (up to 3x) after 10s
      return retryNum < 3 ? 10000 : -1;
    };
    Show
    In 2.0 pollErrorHandler is not customizable and the retry policy is hard coded. An application may want to be notified when reverse AJAX failed and to specify the number of retries and delays between them (e.g. in a clustered environment, we want to retry without a delay a couple of times and then increase the delay). I suggest to add an additional user-level error handler, which takes a retry number (in addition to the error message) and returns the next retry delay or -1 to cancel retrying. For example, a handler, which implements the current retry policy: function(message, ex, retryNum) {   // if anything goes wrong then just silently try again (up to 3x) after 10s   return retryNum < 3 ? 10000 : -1; };
  1. dwr-poll-error-handler.patch
    (4 kB)
    Ilya Perminov
    27/Apr/07 8:09 PM

Activity

Hide
Ilya Perminov added a comment - 27/Apr/07 8:09 PM

A patch, which implements the idea.

Show
Ilya Perminov added a comment - 27/Apr/07 8:09 PM A patch, which implements the idea.
Hide
David Marginian added a comment - 08/Apr/09 9:44 AM

Opinions on the patch?

Show
David Marginian added a comment - 08/Apr/09 9:44 AM Opinions on the patch?
Hide
David Marginian added a comment - 25/May/09 7:09 PM

My thinking is that instead of the patch we can add setters for _maxPollRetries and _retryIntervals.

Show
David Marginian added a comment - 25/May/09 7:09 PM My thinking is that instead of the patch we can add setters for _maxPollRetries and _retryIntervals.
Hide
David Marginian added a comment - 23/Jun/09 4:52 AM

I have added the following setters:

/*

  • The maximum number of retries before failure.
  • @param - maxRetries - The maximum number of retries before failure.
    */
    dwr.engine.setMaxRetries = function(maxRetries) { dwr.engine._maxRetries = maxRetries; };

/*

  • The intervals between successive retries in seconds
  • @param - array of integers representing the retry interval in seconds.
    */
    dwr.engine.setRetryIntervals = function(intervalsArray) { dwr.engine._retryIntervals = intervalsArray; };

After maxRetries has been reached the errorHandler will now be called.

Show
David Marginian added a comment - 23/Jun/09 4:52 AM I have added the following setters: /*
  • The maximum number of retries before failure.
  • @param - maxRetries - The maximum number of retries before failure. */ dwr.engine.setMaxRetries = function(maxRetries) { dwr.engine._maxRetries = maxRetries; };
/*
  • The intervals between successive retries in seconds
  • @param - array of integers representing the retry interval in seconds. */ dwr.engine.setRetryIntervals = function(intervalsArray) { dwr.engine._retryIntervals = intervalsArray; };
After maxRetries has been reached the errorHandler will now be called.
Hide
David Marginian added a comment - 24/Aug/10 5:16 AM

Recent changes have been made:

1) Error handler is called immediately.
2) n-1 retries (where n is _retryIntervals.length) are attempted then the status is changed to offline (pollStatusHandler is called)
3) We continue to poll at _retryIntervals(_retryIntervals - 1) interval while we are offline.
4) When we are online pollStatusHandler is called again.

Show
David Marginian added a comment - 24/Aug/10 5:16 AM Recent changes have been made: 1) Error handler is called immediately. 2) n-1 retries (where n is _retryIntervals.length) are attempted then the status is changed to offline (pollStatusHandler is called) 3) We continue to poll at _retryIntervals(_retryIntervals - 1) interval while we are offline. 4) When we are online pollStatusHandler is called again.
Hide
David Marginian added a comment - 13/Jul/11 4:25 AM

Re-opening this for a minor change.

Show
David Marginian added a comment - 13/Jul/11 4:25 AM Re-opening this for a minor change.

People

Dates

  • Created:
    27/Apr/07 8:07 PM
    Updated:
    13/Jul/11 4:26 AM