热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

ConnectionAbortedError:[WinError10053]已建立的连接已被主机中的软件中止

如何解决《ConnectionAbortedError:[WinError10053]已建立的连接已被主机中的软件中止》经验,为你挑选了1个好方法。

出于某种原因,只有在打开嵌套webdriver实例时才会出现以下错误.不知道这里发生了什么.

我使用的是Windows 10, geckodriver 0.21.0Python 3.7.

ConnectionAbortedError:[WinError 10053]

An established connection was aborted by the software in your host machine

工作正常的脚本的一部分

tab_backers = ff.find_element_by_xpath('//a[@gogo-test="backers_tab"]')

try:
    funding_backers_count = int(''.join(filter(str.isdigit, str(tab_backers.text))))
except ValueError:
    funding_backers_count = 0

if funding_backers_count > 0:
    tab_backers.click()

    see_more_backers = WebDriverWait(ff, 10).until(
        EC.element_to_be_clickable((By.XPATH, '//ui-view//a[text()="See More Backers"]'))
    )
    clicks = 0
    while clicks <0:
        clicks += 1
        ff.WebDriverWait(ff, 5).until(
            see_more_backers.click()
        )

    for container in ff.find_elements_by_xpath('//ui-view//div[@class="campaignBackers-pledge ng-scope"]'):
        backers_profile = container.find_elements_by_xpath('./*/div[@class="campaignBackers-pledge-backer-details"]/a')
        if len(backers_profile) > 0:
            backers_profile = backers_profile[0].get_attribute('href') 
        else:
            backers_profile = 'Unknown'
        backers_name = safe_encode(container.find_element_by_xpath('(./*/div[@class="campaignBackers-pledge-backer-details"]/*)[1]').text)
        backers_timestamp = container.find_element_by_xpath('./*/div[@class="campaignBackers-pledge-backer-details"]/div[contains(@class, "campaignBackers-pledge-backer-details-note")]').text
        backers_cOntribution= container.find_element_by_xpath('./*//*[contains(@class, "campaignBackers-pledge-amount-bold")]').text
        if backers_contribution != 'Private':
            backers_cOntribution= int(''.join(filter(str.isdigit, str(backers_contribution))))
        if backers_profile != 'Unknown':

导致系统中止连接的脚本的一部分

            _ff = create_webdriver_instance()
            _ff.get(backers_profile)
            _ff.quit()

追溯

Traceback (most recent call last):
  File "C:\Users\Anthony\Desktop\test.py", line 271, in 
    backers_profile = container.find_elements_by_xpath('./*/div[@class="campaignBackers-pledge-backer-details"]/a')
  File "C:\Users\Anthony\AppData\Local\Programs\Python\Python37\lib\site-packages\selenium\webdriver\remote\webelement.py", line 381, in find_elements_by_xpath
    return self.find_elements(by=By.XPATH, value=xpath)
  File "C:\Users\Anthony\AppData\Local\Programs\Python\Python37\lib\site-packages\selenium\webdriver\remote\webelement.py", line 680, in find_elements
    {"using": by, "value": value})['value']
  File "C:\Users\Anthony\AppData\Local\Programs\Python\Python37\lib\site-packages\selenium\webdriver\remote\webelement.py", line 628, in _execute
    return self._parent.execute(command, params)
  File "C:\Users\Anthony\AppData\Local\Programs\Python\Python37\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 318, in execute
    respOnse= self.command_executor.execute(driver_command, params)
  File "C:\Users\Anthony\AppData\Local\Programs\Python\Python37\lib\site-packages\selenium\webdriver\remote\remote_connection.py", line 472, in execute
    return self._request(command_info[0], url, body=data)
  File "C:\Users\Anthony\AppData\Local\Programs\Python\Python37\lib\site-packages\selenium\webdriver\remote\remote_connection.py", line 495, in _request
    self._conn.request(method, parsed_url.path, body, headers)
  File "C:\Users\Anthony\AppData\Local\Programs\Python\Python37\lib\http\client.py", line 1229, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "C:\Users\Anthony\AppData\Local\Programs\Python\Python37\lib\http\client.py", line 1275, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "C:\Users\Anthony\AppData\Local\Programs\Python\Python37\lib\http\client.py", line 1224, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "C:\Users\Anthony\AppData\Local\Programs\Python\Python37\lib\http\client.py", line 1055, in _send_output
    self.send(chunk)
  File "C:\Users\Anthony\AppData\Local\Programs\Python\Python37\lib\http\client.py", line 977, in send
    self.sock.sendall(data)
ConnectionAbortedError: [WinError 10053] An established connection was aborted by the software in your host machine

geckodriver.log

这是一个代码,因为它太长了!

create_webdriver_instance函数

def create_webdriver_instance():
    optiOns= Options()
    options.add_argument('-headless')
    try:
        ua_string = random.choice(ua_strings)
        profile = webdriver.FirefoxProfile()
        profile.set_preference('general.useragent.override', ua_string)
        return webdriver.Firefox(profile) # profile, firefox_optiOns=options
    except IndexError as error:
        print('\nSection: Function to Create Instances of WebDriver\nCulprit: random.choice(ua_strings)\nIndexError: {}\n'.format(error))
        return webdriver.Firefox() # firefox_optiOns=options


有没有人知道可能导致连接中止的原因是什么?




1> DebanjanB..:

此错误消息...

ConnectionAbortedError: [WinError 10053] An established connection was aborted by the software in your host machine

...表示新WebBrowsing会话(Firefox浏览器会话)的初始化已中止。


建立的连接被主机中的软件中止了

根据您的代码尝试,错误显然是create_webdriver_instance()包含以下内容的函数:

try:
    ua_string = random.choice(ua_strings)
    profile = webdriver.FirefoxProfile()
    profile.set_preference('general.useragent.override', ua_string)
    return webdriver.Firefox(profile)

和:

except IndexError as error:
    print('\nSection: Function to Create Instances of WebDriver\nCulprit: random.choice(ua_strings)\nIndexError: {}\n'.format(error))
    return webdriver.Firefox()

因此,您不清楚在return webdriver.Firefox(profile)或中哪个功能要面对这个问题webdriver.Firefox()

也许仔细看一下Codepen中的日志,表明错误来自webdriver.Firefox(profile)


原因

该错误背后可能有多种原因:

存在防病毒软件

防火墙阻止端口。

网络配置。

问题可能是由CORS引起的。

由于启用了HTTP保持活动连接


第一步将确定是否有任何软件阻止与计算机中服务器的连接。除此之外,可能的解决方案是:

禁用防病毒软件

禁用防火墙

确保系统上的/ etc / hosts包含以下条目:

127.0.0.1   localhost.localdomain localhost

由于连接被主机中的软件中止,因此您需要允许localhost路由,例如http://localhost:8080/reactive-commands

根据与Geckodriver 0.21.0的Keep-Alive连接,在闲置5s后无需使用Selenium Python客户端重新连接就掉线了

AutomatedTester:此问题不是因为在进行请求时我们尚未连接。如果是这个问题,我们将收到一个抛出的httplib.HTTPConnection异常。相反,当我们进行连接并关闭并尝试解析响应时,将引发BadStatusLine。现在这可能是python stdlib错误,httplib错误或selenium错误。一个Python客户端与别的东西没有表现出与保持活动连接相同的缺陷是取代的urllib WIP

andreastt:该geckodriver团队正在扩展服务器端超时值会更合理。正如我所说,这将有助于缓解此问题,但不能从根本上解决它。无论如何,五秒钟可能太短而无法从持久的HTTP连接中获得真正的好处,将其增加到60秒左右将具有更高的性能。


结论

Selenium 3.14.0刚刚被释放。如果您受到此问题的影响,请相应升级。


参考文献:

带请求的烧瓶破损管

跨域资源共享(CORS)

连接被主机中的软件中止

[WinError 10053]带有0.21.0

闲置5s后,无需使用Selenium Python客户端重新连接,与geckodriver 0.21.0的保持活动连接断开

支持保持活动连接

结构超级::服务器::服务器

urllib3


推荐阅读
  • ScrollView嵌套Collectionview无痕衔接四向滚动,支持自定义TitleView
    本文介绍了如何实现ScrollView嵌套Collectionview无痕衔接四向滚动,并支持自定义TitleView。通过使用MainScrollView作为最底层,headView作为上部分,TitleView作为中间部分,Collectionview作为下面部分,实现了滚动效果。同时还介绍了使用runtime拦截_notifyDidScroll方法来实现滚动代理的方法。具体实现代码可以在github地址中找到。 ... [详细]
  • 本文讨论了在使用Git进行版本控制时,如何提供类似CVS中自动增加版本号的功能。作者介绍了Git中的其他版本表示方式,如git describe命令,并提供了使用这些表示方式来确定文件更新情况的示例。此外,文章还介绍了启用$Id:$功能的方法,并讨论了一些开发者在使用Git时的需求和使用场景。 ... [详细]
  • CF:3D City Model(小思维)问题解析和代码实现
    本文通过解析CF:3D City Model问题,介绍了问题的背景和要求,并给出了相应的代码实现。该问题涉及到在一个矩形的网格上建造城市的情景,每个网格单元可以作为建筑的基础,建筑由多个立方体叠加而成。文章详细讲解了问题的解决思路,并给出了相应的代码实现供读者参考。 ... [详细]
  • Go GUIlxn/walk 学习3.菜单栏和工具栏的具体实现
    本文介绍了使用Go语言的GUI库lxn/walk实现菜单栏和工具栏的具体方法,包括消息窗口的产生、文件放置动作响应和提示框的应用。部分代码来自上一篇博客和lxn/walk官方示例。文章提供了学习GUI开发的实际案例和代码示例。 ... [详细]
  • 欢乐的票圈重构之旅——RecyclerView的头尾布局增加
    项目重构的Git地址:https:github.comrazerdpFriendCircletreemain-dev项目同步更新的文集:http:www.jianshu.comno ... [详细]
  • 本文介绍了一个适用于PHP应用快速接入TRX和TRC20数字资产的开发包,该开发包支持使用自有Tron区块链节点的应用场景,也支持基于Tron官方公共API服务的轻量级部署场景。提供的功能包括生成地址、验证地址、查询余额、交易转账、查询最新区块和查询交易信息等。详细信息可参考tron-php的Github地址:https://github.com/Fenguoz/tron-php。 ... [详细]
  • Android日历提醒软件开源项目分享及使用教程
    本文介绍了一款名为Android日历提醒软件的开源项目,作者分享了该项目的代码和使用教程,并提供了GitHub项目地址。文章详细介绍了该软件的主界面风格、日程信息的分类查看功能,以及添加日程提醒和查看详情的界面。同时,作者还提醒了读者在使用过程中可能遇到的Android6.0权限问题,并提供了解决方法。 ... [详细]
  • 本文介绍了NetCore WebAPI开发的探索过程,包括新建项目、运行接口获取数据、跨平台部署等。同时还提供了客户端访问代码示例,包括Post函数、服务器post地址、api参数等。详细讲解了部署模式选择、框架依赖和独立部署的区别,以及在Windows和Linux平台上的部署方法。 ... [详细]
  • 本文整理了Java中java.lang.NoSuchMethodError.getMessage()方法的一些代码示例,展示了NoSuchMethodErr ... [详细]
  • JVM:33 如何查看JVM的Full GC日志
    1.示例代码packagecom.webcode;publicclassDemo4{publicstaticvoidmain(String[]args){byte[]arr ... [详细]
  • Iamtryingtomakeaclassthatwillreadatextfileofnamesintoanarray,thenreturnthatarra ... [详细]
  • 在Android开发中,使用Picasso库可以实现对网络图片的等比例缩放。本文介绍了使用Picasso库进行图片缩放的方法,并提供了具体的代码实现。通过获取图片的宽高,计算目标宽度和高度,并创建新图实现等比例缩放。 ... [详细]
  • 怎么在PHP项目中实现一个HTTP断点续传功能发布时间:2021-01-1916:26:06来源:亿速云阅读:96作者:Le ... [详细]
  • 导出功能protectedvoidbtnExport(objectsender,EventArgse){用来打开下载窗口stringfileName中 ... [详细]
  • 本文介绍了一种在PHP中对二维数组根据某个字段进行排序的方法,以年龄字段为例,按照倒序的方式进行排序,并给出了具体的代码实现。 ... [详细]
author-avatar
一切皆空2502861573
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有