WSGI error on certain kinds of requests

20 views
Skip to first unread message

Nick K

unread,
Jun 21, 2011, 11:54:18 AM6/21/11
to mod...@googlegroups.com
Hi, all,

I hope this is the right forum (I am very new at this).

I've been trying to get Django to work as a Paypal IPN endpoint, and I've been using wsgi. Basically, Paypal contacts my server with information using a seemingly headerless request.

Here is the entry in the access log:

216.113.191.33 - - [21/Jun/2011:11:42:03 -0400] "POST /ipn_endpoint_test HTTP/1.0" 500 36936 "-" "-"

and here is the error:

[Tue Jun 21 11:42:03 2011] [error] [client 216.113.191.33] mod_wsgi (pid=11130): Exception occurred processing WSGI script '/var/www/wsgi/wsgi.wsgi'.
[Tue Jun 21 11:42:03 2011] [error] [client 216.113.191.33] IOError: failed to write data

What mystifies me is that the script runs perfectly in the browser. The first line of the script being called is a logging entry, and it doesn't even reach that point when PayPal calls it. I also (think) I have Paste's error middleware running, and that's also not registering anything.

(1) Anyone know what could be causing this?
(2) Anyone want to help a poor n00b figure out the best way to debug this?

Thanks so much,

Nick

Nick K

unread,
Jun 21, 2011, 1:56:29 PM6/21/11
to mod...@googlegroups.com
It looks like Paypal IPN uses blank user agent and referrer strings. Is there any reason that these would be automatically blocked, and if so, how can I unblock these sorts of requests (or at least limit them to a particular IP range)?

Gratefully yours,

Nick

Graham Dumpleton

unread,
Jun 21, 2011, 6:08:28 PM6/21/11
to mod...@googlegroups.com
Are you running your application in mod_wsgi daemon mode or embedded mode?

Graham

> --
> You received this message because you are subscribed to the Google Groups
> "modwsgi" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/modwsgi/-/VNgedkT2zvcJ.
> To post to this group, send email to mod...@googlegroups.com.
> To unsubscribe from this group, send email to
> modwsgi+u...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/modwsgi?hl=en.
>

Nick K

unread,
Jun 21, 2011, 10:17:51 PM6/21/11
to mod...@googlegroups.com
Hi, Graham,

Thank you so much for your help. I am running in embedded mode.

Best,

Nick

Graham Dumpleton

unread,
Jun 21, 2011, 10:45:30 PM6/21/11
to mod...@googlegroups.com
On 21 June 2011 23:54, Nick K <nkra...@gmail.com> wrote:
> Hi, all,
> I hope this is the right forum (I am very new at this).
> I've been trying to get Django to work as a Paypal IPN endpoint, and I've
> been using wsgi. Basically, Paypal contacts my server with information using
> a seemingly headerless request.
> Here is the entry in the access log:
> 216.113.191.33 - - [21/Jun/2011:11:42:03 -0400] "POST /ipn_endpoint_test
> HTTP/1.0" 500 36936 "-" "-"
>
> and here is the error:
> [Tue Jun 21 11:42:03 2011] [error] [client 216.113.191.33] mod_wsgi
> (pid=11130): Exception occurred processing WSGI script
> '/var/www/wsgi/wsgi.wsgi'.
> [Tue Jun 21 11:42:03 2011] [error] [client 216.113.191.33] IOError: failed
> to write data

For daemon mode, to get this specific message means that after your
WSGI application has returned a response and while the response
content is being written back from daemon process to Apache child, the
connection between Apache child process and daemon process has been
closed.

Since this is after the WSGI application had returned a response,
including headers, then for 500 to appear in the access log would sort
of imply the WSGI application had returned a 500 response to begin
with, unless Apache child had something rather severe happen. If the
latter happened would expect to see some sort of message in the error
log. Make sure you are looking at the main Apache error log and not
just the virtual host log.

To try and work out what the request and response are, suggest using a
variation of:

http://code.google.com/p/modwsgi/wiki/DebuggingTechniques#Tracking_Request_and_Response

to capture incoming request and the response. If this is a site
servicing a lot of other traffic, modify the wrapper to check
PATH_INFO and only do stuff if request is for that particular URL.

Seeing exactly what is received and returned may help to understand it.

BTW, is PayPal connecting on a SSL connection?

Graham

> What mystifies me is that the script runs perfectly in the browser. The
> first line of the script being called is a logging entry, and it doesn't
> even reach that point when PayPal calls it. I also (think) I have Paste's
> error middleware running, and that's also not registering anything.
> (1) Anyone know what could be causing this?
> (2) Anyone want to help a poor n00b figure out the best way to debug this?
> Thanks so much,
> Nick
>

Reply all
Reply to author
Forward
0 new messages