Python pygodaddy 连接超时

标签 python linux

This page有关于 pygodaddy 的文档,它是一个 python 脚本,用于更新 Go Daddy 的 DNS 中的 IPv4 地址。我使用 pip install pygodaddy 在我的 CentOS 机器上安装了这个包。文档提供了这个例子:

from pygodaddy import GoDaddyClient
client = GoDaddyClient()
if client.login(username, password):
    print client.find_domains()
    client.update_dns_record('sub.example.com', '1.2.3.4')

在我的 CentOS 机器上,我创建了一个名为 godaddy.py 的文件,其中包含以下内容。注意:提供的用户名和密码只是为了演示,并不是我真实的用户名和密码。

#!/usr/bin/env python
import pygodaddy
import logging

from pygodaddy import GoDaddyClient
client = GoDaddyClient()
logging.basicConfig(filename=/var/log/godaddy/godaddy.log, format='%(asctime)S %(message)s', level=logging.DEBUG)
if client.login('36524174', 'Bht45f!as34Ra'):
    print client.find_domains()
    client.update_dns_record('wima2.freekb.net', '12.34.56.78')

当在终端中输入 python godaddy.py 时,有一段时间没有任何反应,最终显示如下:

File "/usr/lib/python2.7/site-packages/requests/adapters.py", line 487, in send
  raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='dns.godaddy.com', port=443): Max retries exceeded with url: /default.aspx (Caused by NewConnectionError('<requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x176e350>: Failed to establish a new connection: [Errno 110] Connection timed out',))

我已经禁用了 iptables。我已将我的脚本的权限设置为 777,归 root:root 所有。

This post建议添加 sleep(int)。我添加了 sleep(1),但我仍然连接超时。

#!/usr/bin/env python
import pygodaddy
import logging
import sleep

from pygodaddy import GoDaddyClient
client = GoDaddyClient()
logging.basicConfig(filename=/var/log/godaddy/godaddy.log, format='%(asctime)S %(message)s', level=logging.DEBUG)
if client.login('36524174', 'Bht45f!as34Ra'):
    time.sleep(1)
    print client.find_domains()
    client.update_dns_record('wima2.freekb.net', '12.34.56.78')

作为 Python 的新手,我不确定如何调试此连接问题。

编辑: 虽然我的 LAN 中确实有一个代理服务器,但我已将我的机器配置为不通过我的代理服务器路由流量。在我的 LAN、Linux 或 Windows 中的任何机器上,我都可以 ping dns.godaddy.com,并且我得到响应,没有丢包,所以我知道我有能力与 dns.godaddy.com 交谈。 python 脚本使用端口 443。如果我尝试 telnet dns.godaddy.com 443,连接超时。

telnet dns.godaddy.com 443
Trying 104.238.65.158. . .
telnet: Unable to connect to remote host: Connection timed out    

我还尝试使用 nmap 查看我的客户端和 dns.godaddy.com 之间的跃点。令我惊讶的是,当在端口 443 上跟踪到 dns.godaddy.com 的路由时,数据包能够一直跳到 dns.godaddy.com。我想知道为什么我使用 telnet 和 python 脚本时连接超时,但 nmap 能够“连接”。

nmap -Pn --traceroute -p 443 dns.godaddy.com

Starting Nmap 6.40 ( http://nmap.org ) at 2017-01-02 19:17 CST
Nmap scan report for dns.godaddy.com (104.238.65.158)
Host is up (0.076s latency).
rDNS record for 104.238.65.158: ip-104-238-65-158.ip.secureserver.net
PORT     STATE      SERVICE
443/tcp  filtered   https

TRACEROUTE (using proto 1/icmp)
HOP RTT       ADDRESS
1    4.67 ms  r1.software.eng.us (192.168.0.1)
2   18.84 ms  142.254.152.173
3   35.83 ms  ae62.applwibp02h.midwest.rr.com (24.164.240.217)
4   28.85 ms  be22.gnfdwibb01r.midwest.rr.com (65.31.113.6)
5   30.93 ms  bu-ether16.chcgildt87w-bcr00.tbone.rr.com (66.109.6.204)
6   33.18 ms  bu-ether11.chctilwc00w-bcr00.tbone.rr.com (66.109.6.21)
7   77.75 ms  4.28.83.74
8   69.48 ms  ip-184-168-0-117.ip.secureserver.net (184.168.0.117)
9   83.20 ms  ip-104-238-65-158.ip.secureserver.net (104.238.65.158)

最佳答案

看起来 pygodaddy 脚本不再正常工作,如下所示:https://github.com/observerss/pygodaddy/issues/22 .其他人改用了 godaddypy 脚本。

关于Python pygodaddy 连接超时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41428590/

相关文章:

c - WIFSTOPPED 无法正常工作

java - Tomcat运行在linux服务器上。从此服务器发出请求时无法获得响应,但在发出远程请求时可以

c - Linux 内核 0.11 中的进程 0 堆栈

给定起始字符串的 Python 暴力组合

python - Matplotlib Contour Clabel 位置

c# - 在 C# 中功能性初始化数组的语法,类似于 python

linux - 通过 SSH 的毫秒计时

python - 递归函数在 Python 中不返回任何内容

python - 使用reportlab生成长表格的pdf

c - 为什么调用 lseek 后读取的文件总是返回 0?