http://www.scriptscoop.com/t/ ecfc9d07d0e0 / using-python-ldquo-requests-rdquo-with-existing-socket-connection.html https://github.com/kennethreitz/requests/issues/1418 http://lukasa.co.uk/2013/01/Choosing_SSL_Version_In_Requests/我试图安装适用于Windows 7的HotFix ,但在安装时,它说"此更新不适用于您的计算机"。I tried to install a HotFix for Windows 7 but on install, it said 'The update is not applicable to your computer'.所以,我不知道这是一个请求模块问题,我的Windows 7 64位计算机,SSL问题,Bing Ads API服务器的阻塞问题。  我在代码中所做的是,我有一个带凭据的YAML文件。  我将该信息拉入并设置变量以生成授权数据和oAuth对象。  奇怪的是,有时候我的脚本会将其发送到最后并从几个不同的帐户获取所有报告,有时它会抛出下面的错误。  我可以直接运行脚本,让它成功,然后再次运行它会失败。So, I don't know if this is a requests module issue, my Windows 7 64-bit computer, an SSL issue, a blocking issue from the Bing Ads API server.  What I'm doing in the code is, I have a YAML file with credentials.  I pull that info in and set the variables to make the authorized data and oAuth objects.  What's weird is, sometimes my script will make it to the end and get all reports from several different accounts, and sometimes it will throw the error below.  I can literally run the script, have it succeed, then run it again, and it will fail.任何人都有任何使用ConnectionResetError的经验,同时从Bing Ads?Anyone have any experience with the ConnectionResetError while pulling down reports from Bing Ads?ConnectionResetError: [WinError 10054](ReportRequestStatus){ ReportDownloadUrl = "https://dvsrdl.api.bingads.microsoft.com/ReportDownload/Download.aspx?q=3eyPfI1CV3gJbYbsnLXHCpPEug%2fsdc3lgmPS%2bGWRac5sgw3dgVqm1g5yR0YkYE050Ky1qGYokzc1LvFC0d8PA1xKC0Cyd5QdWdODzTpEaHay2reY2aiHxBNtf%2bRUEGbrCmWpD6q...etc." Status = "Success" }Downloading from https://dvsrdl.api.bingads.microsoft.com/ReportDownload/Download.aspx?q=3eyPfI1CV3gJbYbsnLXHCpPEug%2fsdc3lgmPS%2bGWRac5sgw3dgVqm1g5yR0YkYE050Ky1qGYokzc1LvFC0d8PA1xKC0Cyd5QdWdODzTpEaHay2reY2aiHxBNtf%2bRUEGbrCmWpD6q...etc.Traceback (most recent call last): File "C:\Python34\lib\site-packages\requests\packages\urllib3\connectionpool.py", line 544, in urlopen body=body, headers=headers) File "C:\Python34\lib\site-packages\requests\packages\urllib3\connectionpool.py", line 341, in _make_request self._validate_conn(conn) File "C:\Python34\lib\site-packages\requests\packages\urllib3\connectionpool.py", line 761, in _validate_conn conn.connect() File "C:\Python34\lib\site-packages\requests\packages\urllib3\connection.py", line 238, in connect ssl_version=resolved_ssl_version) File "C:\Python34\lib\site-packages\requests\packages\urllib3\util\ssl_.py", line 279, in ssl_wrap_socket return context.wrap_socket(sock, server_hostname=server_hostname) File "C:\Python34\lib\ssl.py", line 364, in wrap_socket _context=self) File "C:\Python34\lib\ssl.py", line 578, in __init__ self.do_handshake() File "C:\Python34\lib\ssl.py", line 805, in do_handshake self._sslobj.do_handshake()ConnectionResetError: [WinError 10054] An existing connection was forcibly closed by the remote hostDuring handling of the above exception, another exception occurred:Traceback (most recent call last): File "C:\Python34\lib\site-packages\requests\adapters.py", line 370, in send timeout=timeout File "C:\Python34\lib\site-packages\requests\packages\urllib3\connectionpool.py", line 597, in urlopen _stacktrace=sys.exc_info()[2]) File "C:\Python34\lib\site-packages\requests\packages\urllib3\util\retry.py", line 245, in increment raise six.reraise(type(error), error, _stacktrace) File "C:\Python34\lib\site-packages\requests\packages\urllib3\packages\six.py", line 309, in reraise raise value.with_traceback(tb) File "C:\Python34\lib\site-packages\requests\packages\urllib3\connectionpool.py", line 544, in urlopen body=body, headers=headers) File "C:\Python34\lib\site-packages\requests\packages\urllib3\connectionpool.py", line 341, in _make_request self._validate_conn(conn) File "C:\Python34\lib\site-packages\requests\packages\urllib3\connectionpool.py", line 761, in _validate_conn conn.connect() File "C:\Python34\lib\site-packages\requests\packages\urllib3\connection.py", line 238, in connect ssl_version=resolved_ssl_version) File "C:\Python34\lib\site-packages\requests\packages\urllib3\util\ssl_.py", line 279, in ssl_wrap_socket return context.wrap_socket(sock, server_hostname=server_hostname) File "C:\Python34\lib\ssl.py", line 364, in wrap_socket _context=self) File "C:\Python34\lib\ssl.py", line 578, in __init__ self.do_handshake() File "C:\Python34\lib\ssl.py", line 805, in do_handshake self._sslobj.do_handshake()requests.packages.urllib3.exceptions.ProtocolError: ('Connection aborted.', ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None))During handling of the above exception, another exception occurred:Traceback (most recent call last): File "C:\Users\john.smith\Documents\my files\Programs\Adwords and Bing Ads Pull Down Reports\bingads_yay\testing\version1.py", line 299, in <module> generate_report('Campaign', 'LastMonth', 'Daily') File "C:\Users\john.smith\Documents\my files\Programs\Adwords and Bing Ads Pull Down Reports\bingads_yay\testing\version1.py", line 267, in generate_report overwrite=True, File "C:\Users\john.smith\Documents\my files\Programs\Adwords and Bing Ads Pull Down Reports\bingads_yay\testing\version1.py", line 145, in download_result_file r=s.get(url, stream=True, verify=True) File "C:\Python34\lib\site-packages\requests\sessions.py", line 477, in get return self.request('GET', url, **kwargs) File "C:\Python34\lib\site-packages\requests\sessions.py", line 465, in request resp = self.send(prep, **send_kwargs) File "C:\Python34\lib\site-packages\requests\sessions.py", line 573, in send r = adapter.send(request, **kwargs) File "C:\Python34\lib\site-packages\requests\adapters.py", line 415, in send raise ConnectionError(err, request=request)requests.exceptions.ConnectionError: ('Connection aborted.', ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None))推荐答案 感谢您与我们联系。Thanks for reaching out.你现在还能重现这个问题吗? 如果是这样,请通过Engaging Support粘贴线程与今天的请求/回复联系 - 这将有助于我们的调查。Can you still reproduce the issue as of today?  If so, please reach out to support via the Engaging Support sticky thread with today's requests/responses -- this will help our investigation.谢谢你,b 马特Thank you,Matt 这篇关于ConnectionResetError WinError 10054 - 远程主机强制关闭现有连接 - 在背对背Bing广告报告请求期间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
09-15 06:53