DefaultBodyLimit closing socket #1704
-
Bug ReportVersion├── axum v0.6.2 PlatformLinux home-workstation 6.0.12-300.fc37.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 8 16:58:47 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux DescriptionWhen I have the default server without any further modifications axum::Server::bind(&addr)
.serve(app.into_make_service())
.with_graceful_shutdown(Self::shutdown_signal())
.await.unwrap(); And send more than 2MB request body, it just closes the socket without any response and nothing in the log. I would expect either http response Is this a bug or is it intended behaivor? I was debugging this way longer than I'd expected to. Thanks |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
The default limit does nothing unless the body is consumed by an extractor. It also does use “payload too large” as the status. So there is likely something else wrong. What does your |
Beta Was this translation helpful? Give feedback.
-
My app looks like this: let app = Router::new()
.route("/json/:webhook_id", post(Self::webhook))
.with_state(Arc::clone(&self.config));
let addr = SocketAddr::from((self.config.server.bind_address, self.config.server.bind_port));
info!("Listening on address: {}", addr);
axum::Server::bind(&addr)
.serve(app.into_make_service())
.with_graceful_shutdown(Self::shutdown_signal())
.await.unwrap(); And async fn webhook(
Path(webhook_id): Path<String>,
State(config): State<Arc<MainConfig>>,
Json(payload): Json<serde_json::Value>,
) -> impl IntoResponse {
info!("Processing request: {}", &settings.id);
... When I tried to send dummy request (with body around 10MB) from python import base64
import requests
image = open("2mb-image.jpg", 'rb')
data = base64.b64encode(image.read()).decode('ascii')
response = requests.post(url="http://localhost:3000/json/test", json={
'image1': data,
'image2': data,
'image3': data,
'image4': data,
'image5': data
})
data = response.json()
print(data) I got error
When we tried to call it from dotnet, it returned
And that's it. No error in logs, no 413. .layer(DefaultBodyLimit::disable()) to my app and everything just magically worked. |
Beta Was this translation helpful? Give feedback.
The default limit does nothing unless the body is consumed by an extractor. It also does use “payload too large” as the status.
So there is likely something else wrong. What does your
app
look like?