Skip to content

Nginx connection timeout after ngrest responding with long response #100

@anandbabu141

Description

@anandbabu141

Ngrest is trying to write 6.6 MB response, but the client receives partial response and nginx closes connection after timeout.

The call sequence is: mod_ngrest_handler -> ngrest_server_dispatch:
here context and poolbody are allocated. There is also a PoolRecycler recyclerBody(context.response->poolBody);
This cleans up the poolbody (by destructor) once the ngrest_server_dispatch is returned.
Pool memory is allocated from heap.
However for large nginx handles asynchronously and so response is queued and then written into socket. However by the time, the response is written into socket, the poolbody is cleaned up and so only partial response could be written.
The fix is to copy the response to memory allocated by nginx memory pool in mod_ngrest_write_client_callback and this memory is retained by nginx till the response is completely written to socket.

The fix attached includes other fixes for issues described in #98

mod_ngrest_nginx.c

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions