Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Large request messages - http routes #907

Open
akjt opened this issue Oct 1, 2024 · 5 comments
Open

Large request messages - http routes #907

akjt opened this issue Oct 1, 2024 · 5 comments
Labels
discussion The viability / implementation of the issue is up for debate further information required existing information is lacking, or feedback is required question Issue can be closed by providing information

Comments

@akjt
Copy link

akjt commented Oct 1, 2024

Is there a limit to the size of the request message.

When I run a

curl -x PUT url -H "Content-Type: application/json" -d "JsonMessage"

it seems that when the json message exceeds 1000 bytes I dont get any response back from my end point. In fact, it seems that problem happens somewhere deep inside the crow code, i.e., I dont reach to my callback url.

Curl just replies back with the following:
curl: (52) Empty reply from server

Any help / hint would be much appreciated

@The-EDev

I discovered stream_threshold which is defaulted to around 1MiB, however , this seems to only apply for response body, not request bodies. Is there really no way I can extend the threshold to send larger request bodies

I now tried with debug log enabled and I got some more logs: - please note when reducing the json size I dont see the invalid http method error


(2024-10-02 20:34:02) [DEBUG   ] 0xffffac001160 {0} queue length: 2
Oct 02 20:34:02 ubuntu123 test_app[642467]: (2024-10-02 20:34:02) [DEBUG   ] 0xffffa8002530 timer cancelled: 0xffffb104afb0 0
Oct 02 20:34:02 ubuntu123 test_app[642467]: (2024-10-02 20:34:02) [DEBUG   ] task_timer cancelled: 0xffffb104afb0 0
Oct 02 20:34:02 ubuntu123 test_app[642467]: (2024-10-02 20:34:02) [DEBUG   ] task_timer scheduled: 0xffffb104afb0 1
Oct 02 20:34:02 ubuntu123 test_app[642467]: (2024-10-02 20:34:02) [DEBUG   ] 0xffffa8002530 timer added: 0xffffb104afb0 1
Oct 02 20:34:02 ubuntu123 test_app[642467]: (2024-10-02 20:34:02) [DEBUG   ] 0xffffa8002530 timer cancelled: 0xffffb104afb0 1
Oct 02 20:34:02 ubuntu123 test_app[642467]: (2024-10-02 20:34:02) [DEBUG   ] task_timer cancelled: 0xffffb104afb0 1
Oct 02 20:34:02 ubuntu123 test_app[642467]: (2024-10-02 20:34:02) [DEBUG   ] task_timer scheduled: 0xffffb104afb0 2
Oct 02 20:34:02 ubuntu123 test_app[642467]: (2024-10-02 20:34:02) [DEBUG   ] 0xffffa8002530 timer added: 0xffffb104afb0 2
Oct 02 20:34:02 ubuntu123 test_app[642467]: (2024-10-02 20:34:02) [DEBUG   ] 0xffffa8002530 timer cancelled: 0xffffb104afb0 2
Oct 02 20:34:02 ubuntu123 test_app[642467]: (2024-10-02 20:34:02) [DEBUG   ] task_timer cancelled: 0xffffb104afb0 2
Oct 02 20:34:02 ubuntu123 test_app[642467]: (2024-10-02 20:34:02) [DEBUG   ] 0xffffa8002530 from read(1) with description: "invalid HTTP method"
Oct 02 20:34:02 ubuntu123 test_app[642467]: (2024-10-02 20:34:02) [DEBUG   ] 0xffffa8002530 is_reading 0 is_writing 0
Oct 02 20:34:02 ubuntu123 test_app[642467]: (2024-10-02 20:34:02) [DEBUG   ] 0xffffa8002530 delete (idle) (queue length: 1)
Oct 02 20:34:02 ubuntu123 test_app[642467]: (2024-10-02 20:34:02) [DEBUG   ] 0xffffa8002530 timer cancelled: 0xffffb104afb0 2
Oct 02 20:34:02 ubuntu123 test_app[642467]: (2024-10-02 20:34:02) [DEBUG   ] task_timer cancelled: 0xffffb104afb0 2
Oct 02 20:34:02 ubuntu123 test_app[642467]: (2024-10-02 20:34:02) [DEBUG   ] 0xffffac001160 {0} queue length: 2
Oct 02 20:34:02 ubuntu123 test_app[642467]: (2024-10-02 20:34:02) [DEBUG   ] 0xffffa8002530 timer cancelled: 0xffffb104afb0 0
Oct 02 20:34:02 ubuntu123 test_app[642467]: (2024-10-02 20:34:02) [DEBUG   ] task_timer cancelled: 0xffffb104afb0 0
Oct 02 20:34:02 ubuntu123 test_app[642467]: (2024-10-02 20:34:02) [DEBUG   ] task_timer scheduled: 0xffffb104afb0 1
Oct 02 20:34:02 ubuntu123 test_app[642467]: (2024-10-02 20:34:02) [DEBUG   ] 0xffffa8002530 timer added: 0xffffb104afb0 1
Oct 02 20:34:02 ubuntu123 test_app[642467]: (2024-10-02 20:34:02) [DEBUG   ] 0xffffa8002530 timer cancelled: 0xffffb104afb0 1
Oct 02 20:34:02 ubuntu123 test_app[642467]: (2024-10-02 20:34:02) [DEBUG   ] task_timer cancelled: 0xffffb104afb0 1
Oct 02 20:34:02 ubuntu123 test_app[642467]: (2024-10-02 20:34:02) [DEBUG   ] task_timer scheduled: 0xffffb104afb0 2
Oct 02 20:34:02 ubuntu123 test_app[642467]: (2024-10-02 20:34:02) [DEBUG   ] 0xffffa8002530 timer added: 0xffffb104afb0 2
Oct 02 20:34:02 ubuntu123 test_app[642467]: (2024-10-02 20:34:02) [DEBUG   ] 0xffffa8002530 timer cancelled: 0xffffb104afb0 2
Oct 02 20:34:02 ubuntu123 test_app[642467]: (2024-10-02 20:34:02) [DEBUG   ] task_timer cancelled: 0xffffb104afb0 2
Oct 02 20:34:02 ubuntu123 test_app[642467]: (2024-10-02 20:34:02) [DEBUG   ] 0xffffa8002530 from read(1) with description: "invalid HTTP method"
Oct 02 20:34:02 ubuntu123 test_app[642467]: (2024-10-02 20:34:02) [DEBUG   ] 0xffffa8002530 is_reading 0 is_writing 0
Oct 02 20:34:02 ubuntu123 test_app[642467]: (2024-10-02 20:34:02) [DEBUG   ] 0xffffa8002530 delete (idle) (queue length: 1)
Oct 02 20:34:02 ubuntu123 test_app[642467]: (2024-10-02 20:34:02) [DEBUG   ] 0xffffa8002530 timer cancelled: 0xffffb104afb0 2
Oct 02 20:34:02 ubuntu123 test_app[642467]: (2024-10-02 20:34:02) [DEBUG   ] task_timer cancelled: 0xffffb104afb0 2

@akjt akjt changed the title Large request messages Large request messages - http routes Oct 1, 2024
@gittiver gittiver added the discussion The viability / implementation of the issue is up for debate label Oct 3, 2024
@akjt akjt closed this as completed Oct 3, 2024
@akjt akjt reopened this Oct 4, 2024
@gittiver
Copy link
Member

gittiver commented Oct 4, 2024

Hi, would it be possible to show the source code? Its hard to say something without knowing what is expected.

@akjt
Copy link
Author

akjt commented Oct 4, 2024

    std::future<void >ff;
    crow::App<crow::CORSHandler> m_app;
    
    CROW_ROUTE(m_app, "/traff").methods(crow::HTTPMethod::PUT)(
                [](const crow::request& request, crow::response& response) {
                    std::cout << request.body << std::endl;
                     response.body = "Thanks!";
                     response.end();
                });

   ff = m_app.bindaddr("127.0.0.1")
    .port(5600).stream_threshold(6097152)
    .signal_clear().loglevel(crow::LogLevel::DEBUG)
    .run_async();

@gittiver
Copy link
Member

gittiver commented Oct 4, 2024

The error would be thrown from the http parser if you send an invalid request method - or alternatively if something is wrong with the encoding of the request.
As the request method is on the beginning of the request I would assume there is maybe something wrong with encoding of requests - maybe an overwrite on the client side?
Look first of what is sent - maybe with wireshark to get sure that you see what is going over the wire.

@gittiver gittiver added the question Issue can be closed by providing information label Oct 4, 2024
@akjt
Copy link
Author

akjt commented Oct 4, 2024

By reducing the size of what I send below 1KB it seems to work though

@gittiver
Copy link
Member

gittiver commented Oct 4, 2024

I can't see, what is sent over the wire. so for now I assume, an incorrect Method is sent if request size is above 1K.
The request is encoded on a client not on server side.

@gittiver gittiver added the further information required existing information is lacking, or feedback is required label Oct 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion The viability / implementation of the issue is up for debate further information required existing information is lacking, or feedback is required question Issue can be closed by providing information
Projects
None yet
Development

No branches or pull requests

2 participants