Search code examples
herokurusthttp2actix-web

Using actix-web with HTTP2 support in Heroku


I am trying to deploy one of the actix-web examples that offers HTTP/2 support in Heroku, after having slightly modified it to listen at the provided $PORT number, as well as the way in which certs are loaded -- rather than read from a file, it obtains the public and private key from the environment.

The problem is that, on each request, the Heroku router logs that the connection is closed without a response.

heroku[router]: 
at=error
code=H13
desc="Connection closed without response"
method=GET
status=503
bytes=0
protocol=https

As it worked locally, I suspect the issue is at my dyno's configuration, which is a Hobby ($7/mo), especially at the certs section. As the application expects to receive the cert info from the environmental variables and having that Heroku does not provide you access to their certificates (e.g cert for xxxxx.herokuapp.com), I bought a domain name with the hopes of generating my own. I did, using the following page.

With a self-generated cert, I've tried so far the following, resulting in any of cases in the following errors:

  1. To provide the same pair of keys to the dyno and application. The logs yield the error mentioned above.
  2. Not to provide SSL configuration to the dyno, but to the application. Therefore, https access is disabled and the dyno is not even hit.
  3. Not to provide certs configuration to the app, but to the dyno. The app crashes on boot time.

However, if I remove the related rustls lines, everything works smoothly, but the protocol used is HTTP/1.1.

Therefore, I'd like to kindly ask you:

  • Is there anything fundamentally bad about having the application expecting to load the certs?
  • Should I try other providers? (e.g DigitalOcean, AWS, Google Cloud)
  • Do you have any idea what might make it work in Heroku?

Solution

  • I've just found that Heroku does not support HTTP/2 at the time (source):

    HTTP/2 is not currently supported on Heroku although this may change in future. You can find out about our currently supported HTTP protocols here: https://devcenter.heroku.com/articles/http-routing#http-versions-supported

    For any future developments we recommend subscribing to the Heroku Changelog. This will let you know about updates, improvements and deprecations ahead of time so that you can make any necessary adjustments.