【问题标题】:error: [Errno 32] Broken pipe when paypal calls back to python django app错误:[Errno 32] 贝宝回调 python django 应用程序时管道损坏
【发布时间】:2010-10-27 01:24:17
【问题描述】:

您好,我正在与我的 django 应用进行 papal 集成。

我正在使用来自 svn 和 python 2.6 的最新版本的 django。

但是,我发现每次当 paypal 的沙箱访问我的通知 url 时,我都会得到 500 [Errno 32] Broken pipe my django stack。

有人有类似的经历吗?

干杯,

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
----------------------------------------

【问题讨论】:

    标签: python django paypal


    【解决方案1】:

    第一个错误 Connection reset by peer 显示连接已被 peer 关闭(在您的情况下为 Pypal),对于错误 Broken pipe 会引发此错误当连接突然关闭而没有通知其他对等方(在您的情况下是您的机器)时。

    【讨论】:

    • 那么我能做些什么来防止这种情况发生吗?当我针对贝宝沙箱进行测试时,如果我使用贝宝实时设置,不确定此症状是否会消失。谢谢
    • 另外,我使用 uwsgi+nginx 部署了这个,我仍然得到 500。
    • @Grace Ladder : 就像我说的是 paypal 重置了连接,也许你可以编辑你的答案并添加你用来连接到 paypal 的代码,希望这可以帮助!
    【解决方案2】:

    有两个问题。首先,一些 paypal API(尤其是 MassPay)非常糟糕。

    第二个也是更有可能的问题是,您的服务器是单线程的,并且无法正确向贝宝提出异常。我能够通过使用模拟 paypal IPN 的表单(通过 POST)创建一个 html 文件,然后查看调试结果(或者更好的是,使用像 PyDev 中的调试器)来解决类似的问题。当然,你可以用 curl 做同样的事情。

    【讨论】:

    • 有趣的是,我尝试使用 curl 来模仿帖子数据,django 服务器幸存下来,但是当 paypal 回电时就搞砸了。很快会做更多的检查,干杯
    猜你喜欢
    • 1970-01-01
    • 2014-04-28
    • 1970-01-01
    • 2014-09-28
    • 2013-04-16
    • 1970-01-01
    • 2021-01-04
    • 2017-04-22
    • 2021-10-11
    相关资源
    最近更新 更多