DWR

Catch and handle MSIE's buggy HTTP status codes when using SSL

Details

  • Type: Improvement Improvement
  • Status: Open Open
  • Priority: Normal Normal
  • Resolution: Unresolved
  • Affects Version/s: 2.0.rc2
  • Fix Version/s: 3.0.1
  • Component/s: Engine
  • Description:
    Hide
    When using an SSL connection to a server that uses keep-alive, a bug in Microsoft's Internet Explorer causes DWR to randomly alert 'No data received from server'.

    However, if you neither have control over the browsers nor the server settings, there is a nice workaround. MSIE uses HTTP status codes above 12000 to signal that the SSL connection has been aborted. If a request contains this status code the request can simply be repeated and will probably succeed.

    In DWREngine._stateChange() one could possibly do something like the following:

    var reply = batch.req.responseText;
    var status = batch.req.status;

    switch (status) {
      case 200:
        // normal response handling
        break;

      case 12029:
      case 12030:
      case 12031:
      case 12152:
      case 12159:
        // retry the request
        break;
      
      default:
        DWREngine._handleMetaDataWarning(null, "Received an error code: " +
    batch.req.status);
    }

    Further reading:
    http://community.xajaxproject.org/viewtopic.php?id=972
    http://www.modssl.org/docs/2.5/ssl_faq.html#ToC47
    http://support.microsoft.com/default.aspx?scid=kb;EN-US;q305217

    Was: https://dwr.dev.java.net/issues/show_bug.cgi?id=128
    Show
    When using an SSL connection to a server that uses keep-alive, a bug in Microsoft's Internet Explorer causes DWR to randomly alert 'No data received from server'. However, if you neither have control over the browsers nor the server settings, there is a nice workaround. MSIE uses HTTP status codes above 12000 to signal that the SSL connection has been aborted. If a request contains this status code the request can simply be repeated and will probably succeed. In DWREngine._stateChange() one could possibly do something like the following: var reply = batch.req.responseText; var status = batch.req.status; switch (status) {   case 200:     // normal response handling     break;   case 12029:   case 12030:   case 12031:   case 12152:   case 12159:     // retry the request     break;      default:     DWREngine._handleMetaDataWarning(null, "Received an error code: " + batch.req.status); } Further reading: http://community.xajaxproject.org/viewtopic.php?id=972 http://www.modssl.org/docs/2.5/ssl_faq.html#ToC47 http://support.microsoft.com/default.aspx?scid=kb;EN-US;q305217 Was: https://dwr.dev.java.net/issues/show_bug.cgi?id=128

Activity

Hide
Joe Walker added a comment - 18/Apr/07 4:28 PM

From Corneil du Plessis <corneilATtsctech.com>

The following seemed to work:

DWREngine._stateChange = function(batch) {
if (!batch.completed && batch.req.readyState == 4) {
try {
var reply = batch.req.responseText;
var status = batch.req.status;
switch (status) { case 200: // normal response handling break; case 12029: case 12030: case 12031: case 12152: case 12159: DWREngine._sendData(batch); window.status = "Retrying..."; return; break; default: DWREngine._handleMetaDataWarning(null, "Received an error code: " + batch.req.status); }
if (reply == null || reply == "") { DWREngine._handleMetaDataWarning(null, "No data received from server"); }
else {
var contentType = batch.req.getResponseHeader("Content-Type");
if (!contentType.match(/^text\/plain/) &&
!contentType.match(/^text\/javascript/)) {
if (DWREngine._textHtmlHandler &&
contentType.match(/^text\/html/)) { DWREngine._textHtmlHandler(); }
else { DWREngine._handleMetaDataWarning(null, "Invalid content type from server: '" + contentType + "'"); }
}
else {
if (reply.search("DWREngine._handle") == -1) { DWREngine._handleMetaDataWarning(null, "Invalid reply from server"); }
else { eval(reply); }
}
}

// We're done. Clear up
DWREngine._clearUp(batch);
}
catch (ex) { if (ex == null) ex = "Unknown error occured"; DWREngine._handleMetaDataWarning(null, ex); }
finally {
if (DWREngine._batchQueue.length != 0) { var sendbatch = DWREngine._batchQueue.shift(); DWREngine._sendData(sendbatch); DWREngine._batches[DWREngine._batches.length] = sendbatch; }
}
}
}

I also added this as part of my init.

DWREngine.setAsync(false);
DWREngine.setVerb("POST");

Show
Joe Walker added a comment - 18/Apr/07 4:28 PM From Corneil du Plessis <corneilATtsctech.com> The following seemed to work: DWREngine._stateChange = function(batch) { if (!batch.completed && batch.req.readyState == 4) { try { var reply = batch.req.responseText; var status = batch.req.status; switch (status) { case 200: // normal response handling break; case 12029: case 12030: case 12031: case 12152: case 12159: DWREngine._sendData(batch); window.status = "Retrying..."; return; break; default: DWREngine._handleMetaDataWarning(null, "Received an error code: " + batch.req.status); } if (reply == null || reply == "") { DWREngine._handleMetaDataWarning(null, "No data received from server"); } else { var contentType = batch.req.getResponseHeader("Content-Type"); if (!contentType.match(/^text\/plain/) && !contentType.match(/^text\/javascript/)) { if (DWREngine._textHtmlHandler && contentType.match(/^text\/html/)) { DWREngine._textHtmlHandler(); } else { DWREngine._handleMetaDataWarning(null, "Invalid content type from server: '" + contentType + "'"); } } else { if (reply.search("DWREngine._handle") == -1) { DWREngine._handleMetaDataWarning(null, "Invalid reply from server"); } else { eval(reply); } } } // We're done. Clear up DWREngine._clearUp(batch); } catch (ex) { if (ex == null) ex = "Unknown error occured"; DWREngine._handleMetaDataWarning(null, ex); } finally { if (DWREngine._batchQueue.length != 0) { var sendbatch = DWREngine._batchQueue.shift(); DWREngine._sendData(sendbatch); DWREngine._batches[DWREngine._batches.length] = sendbatch; } } } } I also added this as part of my init. DWREngine.setAsync(false); DWREngine.setVerb("POST");
Hide
Christophe Rufin added a comment - 14/Jun/07 12:09 PM

Hello,

I'm using DWR 1.1.4 within a RIA for Orange Business, Paris. Async is set to true, the verb is "POST".
This MSIE bug has been a real pain for us because we use mutualized reverse proxies with HTTP 1.1 + SSL + Keep-Alive enabled, and our clients use old MSIEs. We can't change our RP settings and we have had this bug (most often with codes 12030, 12151) so I tried your fix and it is not reliable, it seems to works randomly. Setting Async to true or false did not make any difference.

This seems to work better :
Add this into DWREngine._sendData() before sending the request :
batch.req.setRequestHeader("Connection", "close");

I find it elegant because it forces a new connection per DWR request, and the MSIE bug does not show up anymore.

Show
Christophe Rufin added a comment - 14/Jun/07 12:09 PM Hello, I'm using DWR 1.1.4 within a RIA for Orange Business, Paris. Async is set to true, the verb is "POST". This MSIE bug has been a real pain for us because we use mutualized reverse proxies with HTTP 1.1 + SSL + Keep-Alive enabled, and our clients use old MSIEs. We can't change our RP settings and we have had this bug (most often with codes 12030, 12151) so I tried your fix and it is not reliable, it seems to works randomly. Setting Async to true or false did not make any difference. This seems to work better : Add this into DWREngine._sendData() before sending the request : batch.req.setRequestHeader("Connection", "close"); I find it elegant because it forces a new connection per DWR request, and the MSIE bug does not show up anymore.
Hide
Travis Haagen added a comment - 16/Apr/08 5:39 PM

As a warning to others, I just tried the following with DWR 2.0.3, which was suggested by C. Rufin above, and in IE 6 it caused all links in the browser to become unresponsive. DWR communication seemed to still work.

var dwrHeaders = new Object();
dwrHeaders['Connection'] = 'close';
dwr.engine.setHeaders(dwrHeaders);

Show
Travis Haagen added a comment - 16/Apr/08 5:39 PM As a warning to others, I just tried the following with DWR 2.0.3, which was suggested by C. Rufin above, and in IE 6 it caused all links in the browser to become unresponsive. DWR communication seemed to still work. var dwrHeaders = new Object(); dwrHeaders['Connection'] = 'close'; dwr.engine.setHeaders(dwrHeaders);

People

Dates

  • Created:
    23/Feb/07 6:08 PM
    Updated:
    23/Dec/10 9:47 PM