Errno 10060]连接尝试失败,因为经过一段时间后被连接方未正确响应

发布于 2021-01-29 15:13:54

这个问题不太可能对将来的访客有所帮助;它仅与较小的地理区域,特定的时间段或极为狭窄的情况相关,通常不适用于Internet的全球受众。要获得使该问题更广泛适用的帮助请访问帮助中心

7年前关闭。

def check_web_server(host, port, path):
        h = httplib.HTTPConnection(host, port)
        h.request('GET',path)
        resp = h.getresponse()
        print 'HTTP Response:'
        print '   status =', resp.status
        print '   reason =', resp.reason
        print 'HTTP Headers:'
        for hdr in resp.getheaders():
                print '  %s: %s' % hdr

我像这样调用此函数,check_web_server('www.python.org',80,'/') 但它给了我这个错误 error: [Errno 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond

您可以在此处http://pastebin.com/V9KpGkvw清楚看到代码

我在Stackoverflow的此处进行过搜索,但没有找到任何相关问题,对不起,如果我做错了什么,我还是新手。

关注者
0
被浏览
45
1 个回答
  • 面试哥
    面试哥 2021-01-29
    为面试而生,有面试问题,就找面试哥。

    至于ping作品,但telnet端口80没有,HTTP端口80是关闭你的机器上。我假设您的浏览器的HTTP连接通过一个代理(随着浏览的进行,您还将如何阅读stackoverflow?)。您需要在python程序中添加一些处理代理的代码,如下所示:

    使用HTTP PROXY-Python



知识点
面圈网VIP题库

面圈网VIP题库全新上线,海量真题题库资源。 90大类考试,超10万份考试真题开放下载啦

去下载看看