Search code examples
apachehttphttp2

HTTP/2 long timouts at HTTP_TRANSACTION_READ_HEADERS


The Issue:

I've recently been working enabling HTTP/2 for a large PHP+JS application (generally a Backbone-based SPA served by a PHP back-end). While most resources load fine, two requests are getting stuck in the "Stalled" state for exactly 5 minutes before resolving and downloading as normal.

The two request in question are a simple XMLHttpRequest to our back-end and a request for a Font Awesome font file. Other font files and back-end requests are loaded just fine, but these two will consistently hang up when HTTP/2 is enabled.

Debugging Information:

Here are the headers associated with the font file request listed in Chrome's dev tools:

response headers

...and here's the output from chrome://net-internals, with the hangup occurring at HTTP_TRANSACTION_READ_HEADERS (see the dt of almost 30000ms):

net-internals

Further Details:

This application is served using a build of apache2 that includes the mod_http2 module rather than the standard version of apache2 that is packaged with Ubuntu. The same behavior is reported in the latest versions of Firefox, Chrome, and Chrome beta on Ubuntu 16.04.

For the sake of local development, all SSL is being run through a self-signed OpenSSL certificate, generated with OpenSSL version 1.0.2j.

It should also be noted that all other successful requests are running through Backbone-related methods, which delegate to jQuery's $.ajax, where the failed XMLHttpRequest is using the native JS XMLHttpRequest Object.

Thanks for your help.


Solution

  • What version of Apache and mod_http2 are you using?

    There's been a load of fixes for this sort of thing and Apache 2.4.25 is about to be released including those fixes, so suggest you upgrade to that when it comes out in next day or two and try again.

    Alternatively, if you don't want to wait, you can try updating mod_http2 independently by doing the following (assuming Apache is installed in /usr/local/apache2/ but adjust that as appropriate):

    #Download and install mod_http2 outside of a regular Apache release
    #Latest version is here: https://github.com/icing/mod_h2/releases/
    wget https://github.com/icing/mod_h2/releases/download/v1.8.3/mod_http2-1.8.3.tar.gz
    tar -zxvf mod_http2-1.8.3.tar.gz
    cd mod_http2-1.8.3
    ./configure --with-apxs=/usr/local/apache2/bin/apxs
    make
    sudo make install
    

    Then restart Apache and confirm from error log that you are running mod_http2-1.8.3.

    If that doesn't work then raise an issue here: https://github.com/icing/mod_h2/ as the mod_http2 developer (@icing) is very responsive to issues. Assuming this is an Apache bug of course.