DWR

ErrorHandler is not always called

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 2.0.1
  • Fix Version/s: 2.0.2
  • Component/s: Engine
  • Description:
    Hide

    Let's say I have DWR script running in some web browser and then web server it is connected to is suddenly disappear. What I am observing is that errorHandler hook is not being called reliable (it works sometimes on FireFox but almost never works on MS IE 6). I've tried DWR 1.1.3 and 2.0m3 (haven't got chance to try latest releases).

     To work around that I came up with the following code:

    <script type='text/javascript' src='/coordination/dwr/engine.js'></script>
    <script type='text/javascript' src='/coordination/dwr/interface/Counter.js'></script>
    <script type='text/javascript' src='/coordination/dwr/util.js'></script>
    <script type='text/javascript'>
       timestamp = new Date().getTime();
       isServerDown = "Cannot connect to the server, it is running?";

       function checkCounter() {
         setTimeout('checkCounter()', 1000)
         setTimeout('checkTimeout()', 4000)
         try {
           Counter.getStatus(
           {
             timeout:4000,
             callback:function(counter) {
               DWRUtil.setValue("counter", counter);
               timestamp = new Date().getTime();
             },
             errorHandler:function(message) {
               DWRUtil.setValue("counter", isServerDown);
             }
           });
         } catch(e) {
           DWRUtil.setValue("counter", isServerDown);
         }
       }

       function checkTimeout() {
         if((timestamp + 10000) < new Date().getTime()) {
           DWRUtil.setValue("counter", isServerDown);
         }
       }

       function startDemo() {
          document.getElementById("errmsg0").style.display = 'none';
          checkCounter();
       }
    </script>
    </head>
    <body onload="startDemo()">
    ...

     Complete code is included into the Terracotta kit in Spring demo called Coordination, which shows clustered Spring runtime working with DWR. Currently this demo is polling server every so often, which is not efficient and I would appreciate your thoughts how it can be improved
    Show
    Let's say I have DWR script running in some web browser and then web server it is connected to is suddenly disappear. What I am observing is that errorHandler hook is not being called reliable (it works sometimes on FireFox but almost never works on MS IE 6). I've tried DWR 1.1.3 and 2.0m3 (haven't got chance to try latest releases).  To work around that I came up with the following code: <script type='text/javascript' src='/coordination/dwr/engine.js'></script> <script type='text/javascript' src='/coordination/dwr/interface/Counter.js'></script> <script type='text/javascript' src='/coordination/dwr/util.js'></script> <script type='text/javascript'>    timestamp = new Date().getTime();    isServerDown = "Cannot connect to the server, it is running?";    function checkCounter() {      setTimeout('checkCounter()', 1000)      setTimeout('checkTimeout()', 4000)      try {        Counter.getStatus(        {          timeout:4000,          callback:function(counter) {            DWRUtil.setValue("counter", counter);            timestamp = new Date().getTime();          },          errorHandler:function(message) {            DWRUtil.setValue("counter", isServerDown);          }        });      } catch(e) {        DWRUtil.setValue("counter", isServerDown);      }    }    function checkTimeout() {      if((timestamp + 10000) < new Date().getTime()) {        DWRUtil.setValue("counter", isServerDown);      }    }    function startDemo() {       document.getElementById("errmsg0").style.display = 'none';       checkCounter();    } </script> </head> <body onload="startDemo()"> ...  Complete code is included into the Terracotta kit in Spring demo called Coordination, which shows clustered Spring runtime working with DWR. Currently this demo is polling server every so often, which is not efficient and I would appreciate your thoughts how it can be improved
  1. dwr-error-recovery.patch
    (3 kB)
    Ilya Perminov
    27/Apr/07 9:01 PM

Activity

Hide
Ilya Perminov added a comment - 27/Apr/07 9:00 PM

When a batch response is received completely, the engine can check that for every call in the batch either its callback handler or its error handler was invoked.
Any call without a result indicates a communication error.
I have a patch which improves IO error handling in FireFox and IE 6, I did not test it with any other browsers.

Show
Ilya Perminov added a comment - 27/Apr/07 9:00 PM When a batch response is received completely, the engine can check that for every call in the batch either its callback handler or its error handler was invoked. Any call without a result indicates a communication error. I have a patch which improves IO error handling in FireFox and IE 6, I did not test it with any other browsers.
Hide
Ilya Perminov added a comment - 27/Apr/07 9:01 PM

A patch to improve detection of IO-errors.
Function validateBatch checks that there is a result for every call.
It is invoked from the "onload" event hander for iframe-s, and form the _stateChange for XMLHttpRequest-s.

Show
Ilya Perminov added a comment - 27/Apr/07 9:01 PM A patch to improve detection of IO-errors. Function validateBatch checks that there is a result for every call. It is invoked from the "onload" event hander for iframe-s, and form the _stateChange for XMLHttpRequest-s.

People

Dates

  • Created:
    24/Apr/07 5:17 PM
    Updated:
    29/Feb/08 10:29 AM
    Resolved:
    16/May/07 2:19 AM