Search code examples
ruby-on-railsangularjspuma

Puma server log error


I have an AngularJS web application sending requests to a Rails API running in a Puma server.

I see this error in my puma error log once or twice a day:

2015-02-26 23:26:41 +0000: HTTP parse error, malformed request (): #<Puma::HttpParserError: Invalid HTTP format, parsing fails.>
2015-02-26 23:26:41 +0000: ENV: {"rack.version"=>[1, 2], "rack.errors"=>#<File:/home/ubuntu/env/production/www/yanpyapi/log/puma.stderr.log>, "rack.multithread"=>true, "rack.multiprocess"=>false, "rack.run_once"=>false, "SCRIPT_NAME"=>"", "CONTENT_TYPE"=>"text/plain", "QUERY_STRING"=>"", "SERVER_PROTOCOL"=>"HTTP/1.1", "SERVER_SOFTWARE"=>"2.10.1", "GATEWAY_INTERFACE"=>"CGI/1.2"}

I guess I have something wrong in my code. Not sure. Any way to identify where?


Solution

  • Any way to identify where?

    Fork puma repository and add additional logging to methods called parse_error (try to log all request body). Use this way you can find request which caused your problem and investigate it.