From a82f152658fa6866d8fbf6c1f7e477aa6b8b38ce Mon Sep 17 00:00:00 2001 From: Matt Witherspoon <32485495+spoonincode@users.noreply.github.com> Date: Sun, 4 Feb 2024 22:54:03 -0500 Subject: [PATCH] change max inflight bytes/requests from 429 to 503 --- plugins/http_plugin/http_plugin.cpp | 4 ++-- .../eosio/http_plugin/beast_http_session.hpp | 16 ++++++++-------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/plugins/http_plugin/http_plugin.cpp b/plugins/http_plugin/http_plugin.cpp index b58a987f20..ed4f653e56 100644 --- a/plugins/http_plugin/http_plugin.cpp +++ b/plugins/http_plugin/http_plugin.cpp @@ -250,9 +250,9 @@ class http_plugin_impl : public std::enable_shared_from_this { ("max-body-size", bpo::value()->default_value(my->plugin_state->max_body_size), "The maximum body size in bytes allowed for incoming RPC requests") ("http-max-bytes-in-flight-mb", bpo::value()->default_value(500), - "Maximum size in megabytes http_plugin should use for processing http requests. -1 for unlimited. 429 error response when exceeded." ) + "Maximum size in megabytes http_plugin should use for processing http requests. -1 for unlimited. 503 error response when exceeded." ) ("http-max-in-flight-requests", bpo::value()->default_value(-1), - "Maximum number of requests http_plugin should use for processing http requests. 429 error response when exceeded." ) + "Maximum number of requests http_plugin should use for processing http requests. 503 error response when exceeded." ) ("http-max-response-time-ms", bpo::value()->default_value(30), "Maximum time for processing a request, -1 for unlimited") ("verbose-http-errors", bpo::bool_switch()->default_value(false), diff --git a/plugins/http_plugin/include/eosio/http_plugin/beast_http_session.hpp b/plugins/http_plugin/include/eosio/http_plugin/beast_http_session.hpp index e2156489f7..0022cc5a43 100644 --- a/plugins/http_plugin/include/eosio/http_plugin/beast_http_session.hpp +++ b/plugins/http_plugin/include/eosio/http_plugin/beast_http_session.hpp @@ -202,13 +202,13 @@ class beast_http_session : public detail::abstract_conn { virtual bool verify_max_bytes_in_flight() override { auto bytes_in_flight_size = plugin_state_->bytes_in_flight.load(); if(bytes_in_flight_size > plugin_state_->max_bytes_in_flight) { - fc_dlog(plugin_state_->logger, "429 - too many bytes in flight: ${bytes}", ("bytes", bytes_in_flight_size)); + fc_dlog(plugin_state_->logger, "503 - too many bytes in flight: ${bytes}", ("bytes", bytes_in_flight_size)); error_results::error_info ei; - ei.code = static_cast(http::status::too_many_requests); + ei.code = static_cast(http::status::service_unavailable); ei.name = "Busy"; ei.what = "Too many bytes in flight: " + std::to_string( bytes_in_flight_size ); - error_results results{static_cast(http::status::too_many_requests), "Busy", ei}; - send_response( fc::json::to_string( results, fc::time_point::maximum() ), static_cast(http::status::too_many_requests) ); + error_results results{static_cast(http::status::service_unavailable), "Busy", ei}; + send_response( fc::json::to_string( results, fc::time_point::maximum() ), static_cast(http::status::service_unavailable) ); return false; } return true; @@ -220,13 +220,13 @@ class beast_http_session : public detail::abstract_conn { auto requests_in_flight_num = plugin_state_->requests_in_flight.load(); if(requests_in_flight_num > plugin_state_->max_requests_in_flight) { - fc_dlog(plugin_state_->logger, "429 - too many requests in flight: ${requests}", ("requests", requests_in_flight_num)); + fc_dlog(plugin_state_->logger, "503 - too many requests in flight: ${requests}", ("requests", requests_in_flight_num)); error_results::error_info ei; - ei.code = static_cast(http::status::too_many_requests); + ei.code = static_cast(http::status::service_unavailable); ei.name = "Busy"; ei.what = "Too many requests in flight: " + std::to_string( requests_in_flight_num ); - error_results results{static_cast(http::status::too_many_requests), "Busy", ei}; - send_response( fc::json::to_string( results, fc::time_point::maximum() ), static_cast(http::status::too_many_requests) ); + error_results results{static_cast(http::status::service_unavailable), "Busy", ei}; + send_response( fc::json::to_string( results, fc::time_point::maximum() ), static_cast(http::status::service_unavailable) ); return false; } return true;