Search code examples
javatomcatwiresharktcpdump

Recording failed HTTP requests with tcpdump


I have Java webapp running inside Tomcat 7.0.22, from time to time there are HTTP requests that cause HTTP 500 (Unexpected exceptions in my app) in production env. In order to reproduce those errors in a staging environment I'd usually run tcpdump and record all HTTP traffic and then use WireShark to filter packets with http.response.code != 200 or 204 or 302 and run "follow HTTP stream" on each response, thus giving me the request that caused this error. Then I can rerun this request with cURL on the staging environment.

My question is:

  • How can this procedure be done automatically?
  • Is there a way to achieve the same effect (to reproduce errors) with some other technique? (maybe some Filter inside Tomcat)

Thanks

Alex


Solution

  • There are tools that provide such functionality. Actually they even do more: they typically instrument your java code so that can detect which module is responsible on the failure.

    I personally was working for company named Correlsense that implements such solution. It is commercial, but your can start from evaluation version that is distributed for free and can be downloaded from the we site. Alternatively I can offer you to check out newrelic.com that looks better than Correlsense although I personally have not used it but only tried to play a little bit.