Open staninprague opened 3 years ago
We're seeing similar behavior in our system GET requests. After a few requests the handler is not being invoked anymore and connection just hangs. If the keep-alive timer expires, the connection does get terminated, so it feels like the dispatcher doesn't pick up the service call and thinks there's nothing do. FWIW, in our PCAP we also see PSH flag on the last successfully handled request and the request packet had to be reassembled form 2 segments. I wonder if TCP stack is pushing partial or empty buffer confusing the parser.
See PCAP screenshot below:
Expected Behavior
Actix-web should be consistent in handling the handler with missing parameters.
When I have a handler like this:
I might call it with curl like:
Where
-d '{}'
would translate to|item: web::Json<SomeTypeWithNoFields>|
One would expect actix-web to either fail or serve such a request consistently and independent on keep-alive settings.
Current Behavior
When using curl that sends ACK, FIN after request, everything is working in the consistent way - request is always properly served.
When using a client like iOS NSURLSession, several requests might be served well (1 or 2-3). Then at some point (might be second request as well) actix-web responds with ACK for such a request and then nothing happens. Client timeouts (timeout set to 60 seconds, actix-web keep alive is set to 95 seconds in my case).
What I see as a difference between curl and iOS NSURLSession client is sending ACK, FIN (curl) or ACK only (NSURLSession).
Fixing the handler to accept the expected parameter (json) of '{}' solves the issue.
All other handlers are served with no problem at the time when this particular handler with missing parameter is having a problem. My belief is that timeout from the client probably then leads to FIN and next time such a handler works ok, until the next clog.
Here are two subsequent requests from iOS NSURLSession to such a handler that is missing parameter to parse from the request body (handler = account_groups/get_principal_shared_groups):
In the example above, lines 33 -> 38 is an example of the first handling - success. Same request, for the second time in short succession, causes two ACKs from actix-web, but no reply ever, until keep-alive ends or client sends FIN (my guess).
Steps to Reproduce (for bugs)
pub async fn handler( //item: web::Json,
Context
This is based on the error that I made while writing a handler. Though one would expect a consistent behavior of a handler, either to fail every time or to work every time. I was banding my head for a little while until coming to the conclusions on a missing json item parameter vs sending json to this handler.
Your Environment
rustc -V
): rustc 1.51.0 (2fd73fabe 2021-03-23)