Issue in engine.js/_handlePollRetry(), parallel polling after network change ( instead of one ).

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Issue in engine.js/_handlePollRetry(), parallel polling after network change ( instead of one ).

nuwan

Hi,

I found this issue in developing an app with DWR.

file : engine.js
function : dwr.engine._handlePollRetry( )

dwr.engine._handlePollRetry = function(batch, ex) {
      ......
      ......
        var heartbeatInterval = setInterval(function() {
          if (dwr.engine._maxRetries === -1 || dwr.engine._retries < dwr.engine._maxRetries) {
            dwr.engine._execute(null, '__System', 'checkHeartbeat', [ function() {
              // We found a heartbeat, we are back online!
              clearInterval(heartbeatInterval);
              dwr.engine._poll();
            }]);
            ......
          } else {
            .....
          }
        }, retryInterval);
.......
      .......
  };

 The anonymous function here will be invoked multiple times until the connection is back online. Each time scheduling a new 'checkHeartbeat' call. In a temporary connection lost ( as in my case ), connection will be established back before these requests get timed out.

Effect : Soon as server is back online,  dwr.engine._poll(); will be invoked several times causing more than 1 polling requests to be fired. Afterword you'll see application is sending batches of /call/plainpoll/ReverseAjax.dwr requests instead of one.

In one of my cases it started to send these request like 10 requests per every 3 seconds ( 3s is my retryInterval ). Reproducible.

I'm new to DWR, hence I can't accurately suggest how to fix this, but looks like we need to limit 'dwr.engine._poll()' to be invoked only once.

Easy way to recreate : Call, dwr.engine._poll(); several times in the web console.

For me this is a performance issue as I'm developing a mobile app.

Can I get an advice on the suitability of DWR for mobile applications running inside mobile browsers as well mobile web-views ?? Considering following aspects.

- JS Loading performance
- JS execution performance
- Portability

Regards,
Nuwan Abeysinghe



Reply | Threaded
Open this post in threaded view
|

Re: Issue in engine.js/_handlePollRetry(), parallel polling after network change ( instead of one ).

david@butterdev.com
https://directwebremoting.atlassian.net/browse/DWR-654?jql=text%20~%20%22retry%20logic%22

3.0.2 is available in Maven Central, we just haven't sent out the notification yet.  Give it a try and let us know.

On 12/12/2016 07:29 AM, Nuwan wrote:

Hi,

I found this issue in developing an app with DWR.

file : engine.js
function : dwr.engine._handlePollRetry( )

dwr.engine._handlePollRetry = function(batch, ex) {
      ......
      ......
        var heartbeatInterval = setInterval(function() {
          if (dwr.engine._maxRetries === -1 || dwr.engine._retries < dwr.engine._maxRetries) {
            dwr.engine._execute(null, '__System', 'checkHeartbeat', [ function() {
              // We found a heartbeat, we are back online!
              clearInterval(heartbeatInterval);
              dwr.engine._poll();
            }]);
            ......
          } else {
            .....
          }
        }, retryInterval);
.......
      .......
  };

          
 The anonymous function here will be invoked multiple times until the connection is back online. Each time scheduling a new 'checkHeartbeat' call. In a temporary connection lost ( as in my case ), connection will be established back before these requests get timed out.
Effect : Soon as server is back online,  dwr.engine._poll(); will be invoked several times causing more than 1 polling requests to be fired. Afterword you'll see application is sending batches of /call/plainpoll/ReverseAjax.dwr requests instead of one.
In one of my cases it started to send these request like 10 requests per every 3 seconds ( 3s is my retryInterval ). Reproducible.
I'm new to DWR, hence I can't accurately suggest how to fix this, but looks like we need to limit 'dwr.engine._poll()' to be invoked only once.
Easy way to recreate : Call, dwr.engine._poll(); several times in the web console.
For me this is a performance issue as I'm developing a mobile app.
Can I get an advice on the suitability of DWR for mobile applications running inside mobile browsers as well mobile web-views ?? Considering following aspects.
- JS Loading performance
- JS execution performance
- Portability
Regards,
Nuwan Abeysinghe


Reply | Threaded
Open this post in threaded view
|

Re: Issue in engine.js/_handlePollRetry(), parallel polling after network change ( instead of one ).

Mike Wilson
Administrator
(forwarding mail from Nuwan [[hidden email]] below)
 
Noted below lines in 3.0.2 release fixing the issue.

 if (dwr.engine._isHeartbeatBatch(batch)) {
      // Heartbeats should fail fast.
      batch.timeout = 750;
    }

However in my case the browser has to establish a connection ( with SSL ) going through all intermediate proxies ( as network is back ). Most of the request are canceled before they complete. However eventually succeed.

Can we set the value to 950ms without creating any issues ? ( retry interval is 1000ms )


On 12 Dec 2016 10:29 p.m., "Nuwan" <[hidden email]> wrote:

Hi,

I found this issue in developing an app with DWR.

file : engine.js
function : dwr.engine._handlePollRetry( )

dwr.engine._handlePollRetry = function(batch, ex) {
      ......
      ......
        var heartbeatInterval = setInterval(function() {
          if (dwr.engine._maxRetries === -1 || dwr.engine._retries < dwr.engine._maxRetries) {
            dwr.engine._execute(null, '__System', 'checkHeartbeat', [ function() {
              // We found a heartbeat, we are back online!
              clearInterval(heartbeatInterval);
              dwr.engine._poll();
            }]);
            ......
          } else {
            .....
          }
        }, retryInterval);
.......
      .......
  };

 The anonymous function here will be invoked multiple times until the connection is back online. Each time scheduling a new 'checkHeartbeat' call. In a temporary connection lost ( as in my case ), connection will be established back before these requests get timed out.

Effect : Soon as server is back online,  dwr.engine._poll(); will be invoked several times causing more than 1 polling requests to be fired. Afterword you'll see application is sending batches of /call/plainpoll/ReverseAjax.dwr requests instead of one.

In one of my cases it started to send these request like 10 requests per every 3 seconds ( 3s is my retryInterval ). Reproducible.

I'm new to DWR, hence I can't accurately suggest how to fix this, but looks like we need to limit 'dwr.engine._poll()' to be invoked only once.

Easy way to recreate : Call, dwr.engine._poll(); several times in the web console.

For me this is a performance issue as I'm developing a mobile app.

Can I get an advice on the suitability of DWR for mobile applications running inside mobile browsers as well mobile web-views ?? Considering following aspects.

- JS Loading performance
- JS execution performance
- Portability

Regards,
Nuwan Abeysinghe



Reply | Threaded
Open this post in threaded view
|

Re: Issue in engine.js/_handlePollRetry(), parallel polling after network change ( instead of one ).

Mike Wilson
Administrator
Hi Nuwan,
 
(Sorry about the delay. There seems to have been some kind of delivery problem in the mailing list software so I had to resend your mail from my own account.)
 
Sure, increasing the timeout value should have no ill effects. As it's currenly hardcoded you would need to update the source file yourself. The heartbeat timeout could be set up to anything slightly smaller than the heartbeat interval which is the last value of retryIntervals, thus 3000 msec with the default values.
 
We could handle this automatically in DWR and I have created
to be included in the next release.
 
Best regards
Mike Wilson
 
 
Nuwan  wrote: 
Noted below lines in 3.0.2 release fixing the issue.

 if (dwr.engine._isHeartbeatBatch(batch)) {
      // Heartbeats should fail fast.
      batch.timeout = 750;
    }

However in my case the browser has to establish a connection ( with SSL ) going through all intermediate proxies ( as network is back ). Most of the request are canceled before they complete. However eventually succeed.

Can we set the value to 950ms without creating any issues ? ( retry interval is 1000ms )


On 12 Dec 2016 10:29 p.m., "Nuwan" <[hidden email]> wrote:

Hi,

I found this issue in developing an app with DWR.

file : engine.js
function : dwr.engine._handlePollRetry( )

dwr.engine._handlePollRetry = function(batch, ex) {
      ......
      ......
        var heartbeatInterval = setInterval(function() {
          if (dwr.engine._maxRetries === -1 || dwr.engine._retries < dwr.engine._maxRetries) {
            dwr.engine._execute(null, '__System', 'checkHeartbeat', [ function() {
              // We found a heartbeat, we are back online!
              clearInterval(heartbeatInterval);
              dwr.engine._poll();
            }]);
            ......
          } else {
            .....
          }
        }, retryInterval);
.......
      .......
  };

 The anonymous function here will be invoked multiple times until the connection is back online. Each time scheduling a new 'checkHeartbeat' call. In a temporary connection lost ( as in my case ), connection will be established back before these requests get timed out.

Effect : Soon as server is back online,  dwr.engine._poll(); will be invoked several times causing more than 1 polling requests to be fired. Afterword you'll see application is sending batches of /call/plainpoll/ReverseAjax.dwr requests instead of one.

In one of my cases it started to send these request like 10 requests per every 3 seconds ( 3s is my retryInterval ). Reproducible.

I'm new to DWR, hence I can't accurately suggest how to fix this, but looks like we need to limit 'dwr.engine._poll()' to be invoked only once.

Easy way to recreate : Call, dwr.engine._poll(); several times in the web console.

For me this is a performance issue as I'm developing a mobile app.

Can I get an advice on the suitability of DWR for mobile applications running inside mobile browsers as well mobile web-views ?? Considering following aspects.

- JS Loading performance
- JS execution performance
- Portability

Regards,
Nuwan Abeysinghe