当PayPal回调Python Django应用程序时,出现错误:[Errno 32]损坏的管道。

3

你好,我正在将PayPal集成到我的Django应用程序中。

我正在使用最新版本的SVN Django和Python 2.6。

然而,我发现每当PayPal沙箱访问我的通知URL时,我都会在我的Django堆栈中收到500 [Errno 32] Broken pipe错误。

有人有类似的经验吗?

谢谢。

Traceback (most recent call last):
  File "/usr/lib/python2.6/dist-packages/django/core/servers/basehttp.py", line 281, in run
    self.finish_response()
  File "/usr/lib/python2.6/dist-packages/django/core/servers/basehttp.py", line 321, in finish_response
    self.write(data)
  File "/usr/lib/python2.6/dist-packages/django/core/servers/basehttp.py", line 417, in write
    self._write(data)
  File "/usr/lib/python2.6/socket.py", line 318, in write
    self.flush()
  File "/usr/lib/python2.6/socket.py", line 297, in flush
    self._sock.sendall(buffer(data, write_offset, buffer_size))
error: [Errno 104] Connection reset by peer
----------------------------------------
Exception happened during processing of request from ('216.113.191.33', 21736)
Traceback (most recent call last):
  File "/usr/lib/python2.6/SocketServer.py", line 283, in _handle_request_noblock
    self.process_request(request, client_address)
  File "/usr/lib/python2.6/SocketServer.py", line 309, in process_request
    self.finish_request(request, client_address)
  File "/usr/lib/python2.6/SocketServer.py", line 322, in finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "/usr/lib/python2.6/dist-packages/django/core/servers/basehttp.py", line 562, in __init__
    BaseHTTPRequestHandler.__init__(self, *args, **kwargs)
  File "/usr/lib/python2.6/SocketServer.py", line 618, in __init__
    self.finish()
  File "/usr/lib/python2.6/SocketServer.py", line 661, in finish
    self.wfile.flush()
  File "/usr/lib/python2.6/socket.py", line 297, in flush
    self._sock.sendall(buffer(data, write_offset, buffer_size))
error: [Errno 32] Broken pipe
----------------------------------------
2个回答

0

第一个错误Connection reset by peer告诉你连接已被对等方(在你的情况下是Pypal)关闭,而错误Broken pipe则是当连接突然关闭而没有通知另一端(在你的情况下是你的机器)时引发的。


那么有什么我可以做来防止这种情况发生吗? 因为我正在对PayPal沙盒进行测试,不确定如果我使用PayPal实时设置,这种症状是否会消失。谢谢。 - Grace Ladder
同时,我使用uwsgi+nginx部署了它,但仍然出现了500错误。 - Grace Ladder
@Grace Ladder:就像我之前说的,是 PayPal 重置了连接,也许你可以编辑你的答案并添加连接到 PayPal 所使用的代码,希望这能帮助到你! - mouad

0

有两个问题。首先,一些PayPal API(特别是MassPay)非常糟糕。

第二个问题更可能出现,即您的服务器是单线程的,并且在向PayPal正确引发异常方面遇到了麻烦。我能够通过创建一个带有表单的HTML文件(通过POST)来模拟PayPal IPN,然后查看调试结果(或者更好地使用像PyDev中的调试器一样的工具)来解决类似的问题。当然,您也可以使用curl进行相同的操作。


有趣的是,我尝试使用curl模拟POST数据,Django服务器幸存了下来,但当PayPal回调时出现了问题。很快会进行更多检查,祝好。 - Grace Ladder

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接