简体   繁体   English

连接中止。,Django 中的错误(104,“对等连接重置”)

[英]Connection aborted., error(104, 'Connection reset by peer') in Django

I have created an API in Django and inside that calling a third party API which accepts XML data.我在 Django 中创建了一个 API,并在其中调用了一个接受 XML 数据的第三方 API。 With 30 rows of XML it is working fine, for more rows throwing the error "Connection aborted.', error(104, 'Connection reset by peer')".使用 30 行 XML 它工作正常,更多行抛出错误“连接中止。',错误(104,'连接重置由对等')”。 The third party also provided a UI so I can test that up to 5000 rows they are accepting and returning proper result.第三方还提供了一个 UI,因此我可以测试他们接受的多达 5000 行并返回正确的结果。 The connection is not getting closed from either of the APIs.连接未从任一 API 关闭。 What issue can it be?可能是什么问题?

Expected Result预期结果

The post request should work properly for more data in the request as it is working fine for fewer data.对于请求中的更多数据,post 请求应该可以正常工作,因为它对于较少的数据可以正常工作。

Actual Result实际结果

ConnectionError at /v1/send-sms/
('Connection aborted.', error(104, 'Connection reset by peer'))
Request Method: POST
Request URL:    http://example.com/v1/send-sms/
Django Version: 1.11
Exception Type: ConnectionError
Exception Value:    
('Connection aborted.', error(104, 'Connection reset by peer'))
Exception Location: /home/user-135/sandbox/venv/local/lib/python2.7/site-packages/requests/adapters.py in send, line 490
Python Executable:  /home/user-135/sandbox/venv/bin/python
Python Version: 2.7.12
Python Path:    
['/home/user-135/public_html/MyProject',
 '/home/user-135/sandbox/venv/lib/python2.7',
 '/home/user-135/sandbox/venv/lib/python2.7/plat-x86_64-linux-gnu',
 '/home/user-135/sandbox/venv/lib/python2.7/lib-tk',
 '/home/user-135/sandbox/venv/lib/python2.7/lib-old',
 '/home/user-135/sandbox/venv/lib/python2.7/lib-dynload',
 '/usr/lib/python2.7',
 '/usr/lib/python2.7/plat-x86_64-linux-gnu',
 '/usr/lib/python2.7/lib-tk',
 '/home/user-135/sandbox/venv/local/lib/python2.7/site-packages',
 '/home/user-135/public_html/MyProject',
 '/home/user-135/public_html/MyProject']
Server time:    Wed, 7 Mar 2018 10:55:19 +0530

Reproduction Steps繁殖步骤

import requests

recievers = ''
url = 'https://example.com/sms/'
for x in xrange(0, len(users)):
    y = x + 1
    body_content = body
    phone = mobile_no
    recievers = recievers + "<SMS>.......</SMS>"

xml = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n<!DOCTYPE MESSAGE SYSTEM \"http://127.0.0.1:80/sms/ttr/sms.ptp\">\n<MESSAGE VER=\"1.2\">\n<USER USERNAME=\""+username+"\" PASSWORD=\""+password+"\" />"+recievers+"\n</MESSAGE>"

querystring = {"data": xml,"action":"send"}
headers = {'content-type': "application/xml"}
response = requests.request("POST", url, headers=headers, params=querystring)

Try replacing "params=querystring" with "data=querystring"尝试用“data=querystring”替换“params=querystring”

 response = requests.request("POST", url, headers=headers, data=querystring)

params seems to be for GET requests and may by your request URL becomes too long after 30 lines of XML. params 似乎是针对 GET 请求的,并且在 30 行 XML 之后,您的请求 URL 可能会变得太长。

From docs at : http://docs.python-requests.org/en/master/user/quickstart/来自以下文档: http : //docs.python-requests.org/en/master/user/quickstart/

I had a similar case.我有一个类似的案例。 This error was given by the console when I accessed the delete method via the my API.当我通过我的 API 访问 delete 方法时,控制台给出了这个错误。 The problem was solved by fixing the delete function in the view.py file, namely the status argument of Response function that this method returned问题通过修复view.py文件中的delete函数解决,即该方法返回的Response函数的status参数

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 将Selenium与ChromeDriver和Chrome通过Python结合使用时,“连接异常中止”,ConnectionResetError(104,“对等连接重置”) - 'Connection aborted.', ConnectionResetError(104, 'Connection reset by peer') using Selenium with ChromeDriver and Chrome through Python Python 脚本失败并出现('连接中止。',ConnectionResetError(104,'对等连接重置')) - Python script is failing with ('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer')) requests.exceptions.ConnectionError: (&#39;Connection aborted.&#39;, ConnectionResetError(104, &#39;Connection reset by peer&#39;)) - requests.exceptions.ConnectionError: ('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer')) 发出WSDL请求,获取连接错误:(&#39;连接中止。&#39;,错误(54,&#39;通过对等方重置连接&#39;)) - Making WSDL request, Getting Connection Error: ('Connection aborted.', error(54, 'Connection reset by peer')) django errno 104 连接由对等方重置 - django errno 104 Connection reset by peer Python错误104,由同行重置连接 - Python Error 104, connection reset by peer 对等的104管道故障和连接重置 - Broken pipe error and connection reset by peer 104 尝试发布到gfycat.com时,Python请求提供错误信息(“连接已中止。”,错误(“(104,&#39;ECONNRESET&#39;)”,))) - Python requests giving error ('Connection aborted.', error(“(104, 'ECONNRESET')”,)) when attempting to post to gfycat.com 错误处理:Boto:[错误 104] 对等方的连接重置 - Error Handling: Boto: [Error 104] Connection Reset by Peer Python socket.error:[Errno 104]由peer重置连接 - Python socket.error: [Errno 104] Connection reset by peer
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM