You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've got a simple API that currently functions perfectly on my local machine. Actix Web with SQLx building a pool for a MariaDB instance. When I try to deploy on Render and AWS, I get a PoolTimedOut error every time. I have no clue why this is happening only in remote hosted instances. I assume I'm doing something wrong, but this is my first time hosting a Rust built API remotely.
Here is the backtrace:
Jun 21 10:02:32 PM note: Some details are omitted, run with RUST_BACKTRACE=full for a verbose backtrace.
Jun 21 10:03:03 PM thread 'main' panicked at 'Error building a connection pool: PoolTimedOut', src/main.rs:107:10
Jun 21 10:03:03 PM stack backtrace:
Jun 21 10:03:03 PM 0: rust_begin_unwind
Jun 21 10:03:03 PM at ./rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/panicking.rs:578:5
Jun 21 10:03:03 PM 1: core::panicking::panic_fmt
Jun 21 10:03:03 PM at ./rustc/90c541806f23a127002de5b4038be731ba1458ca/library/core/src/panicking.rs:67:14
Jun 21 10:03:03 PM 2: core::result::unwrap_failed
Jun 21 10:03:03 PM at ./rustc/90c541806f23a127002de5b4038be731ba1458ca/library/core/src/result.rs:1687:5
Jun 21 10:03:03 PM 3: std::thread::local::LocalKey::with
Jun 21 10:03:03 PM 4: <core::pin::Pin
as core::future::future::Future>::poll
Jun 21 10:03:03 PM 5: tokio::runtime::scheduler::current_thread::CurrentThread::block_on
Jun 21 10:03:03 PM 6: tokio::runtime::runtime::Runtime::block_on
Jun 21 10:03:03 PM 7: fra_api::main
And here is my code:
use actix_web::{
dev::ServiceRequest,
error::Error,
web::{self, Data},
App, HttpMessage, HttpServer,
};
use dotenv::dotenv;
use sqlx::{mysql::MySqlPoolOptions, MySqlPool};
use actix_web_httpauth::{
extractors::{
bearer::{self, BearerAuth},
AuthenticationError,
},
middleware::HttpAuthentication,
};
use hmac::{Hmac, Mac};
use jwt::{Claims, VerifyWithKey};
use serde::{Deserialize, Serialize};
use sha2::Sha256;
mod services;
use services::auth::{generate_api_token, generate_app_token, login};
pub struct AppState {
db: MySqlPool,
}
...
#[actix_web::main]
async fn main() -> std::io::Result<()> {
dotenv().ok();
let database_url = std::env::var("DATABASE_URL").expect("DATABASE_URL must be set");
let pool = MySqlPoolOptions::new()
.max_connections(5)
.connect(&database_url)
.await
.expect("Error building a connection pool");
HttpServer::new(move || {
let app_bearer_middleware = HttpAuthentication::bearer(app_validator);
let api_bearer_middleware = HttpAuthentication::bearer(api_validator);
App::new()
.app_data(Data::new(AppState { db: pool.clone() }))
.service(generate_api_token)
.service(generate_app_token)
.service(
web::scope("v1")
.service(
web::scope("auth")
.wrap(app_bearer_middleware)
.service(login),
)
.service(web::scope("").wrap(api_bearer_middleware)),
)
})
.bind(("127.0.0.1", 8080))?
.run()
.await
}
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I've got a simple API that currently functions perfectly on my local machine. Actix Web with SQLx building a pool for a MariaDB instance. When I try to deploy on Render and AWS, I get a PoolTimedOut error every time. I have no clue why this is happening only in remote hosted instances. I assume I'm doing something wrong, but this is my first time hosting a Rust built API remotely.
Here is the backtrace:
And here is my code:
Beta Was this translation helpful? Give feedback.
All reactions