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 can't figure out how to make a simple HTTP request from AWS Lambda using rust without getting a segmentation fault. I get this error regardless of whether I use tokio-0.2 or tokio-0.3 with a compatibility layer. It looks like lambda_http was compiled with tokio-0.2 so it should work.
Cargo.toml:
[package]
name = "req"version = "0.1.0"authors = ["X"]
edition = "2018"# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
lambda_http = { version = "0.2.0-beta.1", git = "https://github.com/awslabs/aws-lambda-rust-runtime" }
tokio = { version = "0.3.4", features = ["full"] }
tokio-compat-02 = "0.1.2"reqwest = { version = "0.10.9", features = ["json"] }
main.rs
use lambda_http::{
handler,
lambda::{self,Context},IntoResponse,Request,};// NOTE:// when using tokio-0.2 alone, you get a segmentation fault// when tokio-0.2 compatibility is enabled with tokio-0.3, you get a segmentation fault// when tokio-0.2 compatibility is not enabled with tokio-0.3, 'main' panics because 'there is// no reactor running, must be called from the context of Tokio runtime'// use tokio_compat_02::FutureExt;pubtypeError = Box<dyn std::error::Error + Send + Sync + 'static>;#[tokio::main]asyncfnmain() -> Result<(),Error>{
lambda::run(handler(func)).await?;// NOTE: [tokio-0.2 compat] - this doesn't help// lambda::run(handler(func)).compat().await?;Ok(())}asyncfnfunc(_:Request, _:Context) -> Result<implIntoResponse,Error>{let _res = reqwest::get("https://www.google.com").await?;// NOTE: [tokio-0.2 compat] - this doesn't help// let _res = reqwest::get("https://www.google.com").compat().await?;Ok("success")}
I think it is connected to openssl crate, which dyanamically links to glibc.
To check if is it error cause or no, you can depend on reqwest as follows:
I can't figure out how to make a simple HTTP request from AWS Lambda using rust without getting a segmentation fault. I get this error regardless of whether I use tokio-0.2 or tokio-0.3 with a compatibility layer. It looks like
lambda_http
was compiled with tokio-0.2 so it should work.Cargo.toml
:main.rs
deploy.sh
:event.json
The text was updated successfully, but these errors were encountered: