Subject: | Client get 200 status code when connection timeout from client side, but corresponding Apache's error code is 500 |
Date: | Wed, 11 Feb 2015 15:46:56 +0800 |
To: | bug-libwww-perl [...] rt.cpan.org |
From: | Wenjunh <huangwenjun310 [...] gmail.com> |
Hi, all
I am using the libwww-perl module in my production environment to serve entity upload/download current time, but I found an strange error sometimes when my serving apache server gets heavy requests.
This is use case:
I have a client which wraps the LWP::UserAgent instance and set the timeout to 2s($ua->timeout(2)) and then send request to apache which acts as an endpoint of a backend storage. And I have met the incorrect result:
The Apache response code is 500 from access log, but the client get 200 status code, so I will get a partial entity and thought it is success, but it do not conform the truth.
I have some rough analysis and experiment to this issue:
1. When using tcpdump to dump the response data, I can see the client gets 200 http status code in the header before it gets the response body.
2. Quickly I hang the data server which will not transfer data to apache, and apache has already return some body-data to the client.
3. The client did not get data from server for more than 2s and it will timeout, and then disconnect from the server.
4. The client parse the HTTP response with header contains 200 status code, so it thoughts that it has got the entity successfully and return an error entity with partial body-content.
I have also used similar java HTTP client sdk to do the similar job, which will get 500 status code when client timeout occurs. So I think it may be a bug for libwww-perl module, which lacks integrity checking after the connection closed.
Below is some information of my environment:
The data path: Client(libwww-perl) <----> HTTP Server(Apache/2.2.26 (Unix)) <----> Internal Data Server
OS with libwww-perl installed: rhel-6.5(2.6.32-431.3.1.el6.x86_64)
Looking forward for your response!
Thanks
Wenjun