0

I have a wierd 504 error occuring in Apache + mod_wsgi when I post a specific SVG string. The backend application is Python Flask, but it does not seem to get to the application at all.

Here is one request that returns a 504 error:

curl 'https://some.domain.com/api/export/png' --data 'svg=%22%3E%28style' 

And here is another one that returns with 200:

curl 'https://some.domain.com/api/export/png' --data 'svg=%22%3E%28styl' 

The difrrerence is that I only removed one character from the POST data

The SVG data is cut down to the smallest one that could produce an error. The original SVG string is much larger.

The error that appears in the apache error log is:

[Tue Jun 09 14:27:26 2015] [error] [client X.X.X.X] (104)Connection  reset by peer: mod_wsgi (pid=19254): Unable to get bucket brigade for request., referer: https://some.domain.com/
[Tue Jun 09 14:27:26 2015] [error] [client X.X.X.X] mod_wsgi (pid=19252): Exception occurred processing WSGI script '/var/www/ade/src/interface.wsgi'.
[Tue Jun 09 14:27:26 2015] [error] [client X.X.X.X] IOError: failed to write data

It is interestig that the the error appears in the error log imidietly after I make the request, before the post data upload finishes.

Here are the version numbers we have:

Ubunut 12.04
Apache/2.2.22 (Ubuntu) 
mod_ssl/2.2.22 
OpenSSL/1.0.1 
mod_wsgi/3.3 
Python/2.7.3

Any clues what might be causing this?

UPDATE: We updated mod_wsgi to 4.4.12 and the error message changed in the error.log

[Wed Jun 10 05:48:35 2015] [error] [client X.X.X.X] mod_wsgi (pid=5019): Request data read error when proxying data to daemon process: Connection reset by peer., referer: http://devade.annalect.com/

This might be related to AWS load balancers in front of the web server. Will try to investigate on that end. http://docs.aws.amazon.com/ElasticLoadBalancing/latest/DeveloperGuide/ts-elb-error-message.html#ts-elb-errorcodes-http504

Martin Taleski
  • 6,033
  • 10
  • 40
  • 78
  • Are you using mod_wsgi embedded mode or daemon mode? Can you not use such an ancient mod_wsgi version? – Graham Dumpleton Jun 09 '15 at 21:58
  • @GrahamDumpleton, I have just updated to 3.5, I get the same thing. It is running in daemon mode – Martin Taleski Jun 10 '15 at 08:36
  • The latest version is 4.4.12. Version 3.5 is still very out of date. – Graham Dumpleton Jun 10 '15 at 09:18
  • @GrahamDumpleton, just updated to 4.4.12 from git hub master branch. Still getting the 504 error, but the error message in apache error.log changed (see update on question). This might not be related to mod_wsgi at all... there is a AWS load balancer in front of apache, so trying to investiagete on that end. – Martin Taleski Jun 10 '15 at 09:56
  • What do you have the Timeout directive set to in Apache configuration? What options are you giving to WSGIDaemonProcess directive? How long does the application take to handle this request? – Graham Dumpleton Jun 10 '15 at 11:24
  • @GrahamDumpleton it turned out that a buggy firewall was closing the connection for some reason. After switching it off, it works. Thanks for your involvement, mod_wsgi is working great. – Martin Taleski Jun 10 '15 at 20:39
  • Okay, thanks for letting me know. I suspected that it was due to a connection being cut off, but wasn't obvious why so far. One cause which was pursuing was a Timeout value which was set to be a very low value, but even then that didn't make sense where so little data involved. – Graham Dumpleton Jun 10 '15 at 23:14

0 Answers0