emk / heroku-buildpack-rust

A buildpack for Rust applications on Heroku, with full support for Rustup, cargo and build caching.
523 stars 186 forks source link

Need help! Error R10 - Boot timeout -> failed to bind to $PORT within 60 seconds #44

Closed JakubKoralewski closed 5 years ago

JakubKoralewski commented 5 years ago

The build succeeds. I am using actix-web 0.7, diesel 1.4.2. This is my repo. Here's what the Heroku logs have to say about my error. I am binding to the correct PORT it seems that is set in the env variables. Once I release for 60 seconds I can try to access the API endpoints, but for this time I can't connect. I get a spinning circle and once the time passes I get an Application Error response in the browser.

Starting process with command `./target/release/dziennik-rust` 
Apr 20 05:10:15 dziennik-rust app/web.1:  DEBUG dziennik_rust > Listening on 127.0.0.1:21674 
Apr 20 05:10:16 dziennik-rust app/web.1:  INFO  actix_net::server::server > Starting 8 workers 
Apr 20 05:10:16 dziennik-rust app/web.1:  INFO  actix_net::server::server > Starting server on 127.0.0.1:21674 
Apr 20 05:10:16 dziennik-rust app/web.1:  DEBUG tokio_reactor             > adding I/O source: 0 
Apr 20 05:10:16 dziennik-rust app/web.1:  DEBUG tokio_reactor             > adding I/O source: 4194305 
Apr 20 05:10:16 dziennik-rust app/web.1:  DEBUG tokio_reactor             > adding I/O source: 8388610 
Apr 20 05:10:16 dziennik-rust app/web.1:  DEBUG tokio_reactor             > adding I/O source: 12582915 
Apr 20 05:10:16 dziennik-rust app/web.1:  DEBUG tokio_reactor             > adding I/O source: 16777220 
Apr 20 05:10:16 dziennik-rust app/web.1:  DEBUG tokio_reactor::registration > scheduling Read for: 0 
Apr 20 05:10:16 dziennik-rust app/web.1:  DEBUG tokio_reactor::registration > scheduling Read for: 1 
Apr 20 05:10:16 dziennik-rust app/web.1:  DEBUG tokio_reactor::registration > scheduling Read for: 2 
Apr 20 05:10:16 dziennik-rust app/web.1:  DEBUG tokio_reactor::registration > scheduling Read for: 3 
Apr 20 05:10:16 dziennik-rust app/web.1:  DEBUG tokio_reactor::registration > scheduling Read for: 4 
Apr 20 05:10:48 dziennik-rust heroku/web.1: State changed from crashed to starting 
Apr 20 05:11:14 dziennik-rust heroku/web.1: State changed from starting to crashed 
Apr 20 05:11:14 dziennik-rust heroku/web.1: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch 
Apr 20 05:11:14 dziennik-rust heroku/web.1: Stopping process with SIGKILL 

I don't think it's the problem, but I got this error on Sentry. It happened only once, but I tried releasing much more often than that, so I don't think that's the problem. I have used heroku local to bind to the PostgreSQL database on Heroku's AWS and it all works fine. It's just that it doesn't work on Heroku.

Can it be this? I am leveraging auto reload with listenfd. Maybe it's somehow blocking Heroku from recognising the correct port?

emk commented 5 years ago

Hello! Thank you for the bug report.

I'm very sorry, but I'm unlikely to be able to help you very much with this error. Everything I know about getting Heroku to work with actix can be found in https://github.com/emk/rust-buildpack-example-actix. The last I checked, that can be deployed to Heroku and it works.

If you try deploying buildpack-example-actix, does it work? What if you update that project to the latest version of actix?

JakubKoralewski commented 5 years ago

Thanks for the example! I did everything like it's done there. It works now!!! I didn't do it the scientific way so I still don't know which one it was, but it's one of or the combination of these differences:

timmyjose commented 4 years ago

Thanks for the example! I did everything like it's done there. It works now!!! I didn't do it the scientific way so I still don't know which one it was, but it's one of or the combination of these differences:

* bind using a tuple

* parse the $PORT using .parse()

* use ip 0.0.0.0 instead of 127.0.0.1

Confirming with latest Rust builds - using 0.0.0.0 along with the port as a tuple works!

piavgh commented 3 years ago

Thanks for the example! I did everything like it's done there. It works now!!! I didn't do it the scientific way so I still don't know which one it was, but it's one of or the combination of these differences:

  • bind using a tuple
  • parse the $PORT using .parse()
  • use ip 0.0.0.0 instead of 127.0.0.1

Hi,

I checked the source code of that project:

// Get the port number to listen on.
    let port = env::var("PORT")
        .unwrap_or_else(|_| "3000".to_string())
        .parse()
        .expect("PORT must be a number");

    // Start a server, configuring the resources to serve.
    server::new(|| {
        App::new()
            .resource("/", |r| r.f(greet))
            .resource("/{name}", |r| r.f(greet))
    })
    .bind(("0.0.0.0", port))
    .expect("Can not bind to port 8000")
    .run();

But now Rocket does not even have the main function. What should I do to change this?