无法连接到 {}:{}".format(hostname, reason)

Unable to connect to {}: {}".format(hostname, reason)

我的下面某天前工作正常,现在突然停止工作了。当我 运行 文件时出现以下错误。

Traceback (most recent call last):
  File "/app/www/html/project/connect.py", line 8, in <module>
    transport = paramiko.Transport((host, port))
  File "/usr/local/lib/python3.6/site-packages/paramiko/transport.py", line 416, in __init__
    "Unable to connect to {}: {}".format(hostname, reason)
paramiko.ssh_exception.SSHException: Unable to connect to mft.schneider-electric.com: [Errno 110] Connection timed out

这是我的代码。

import paramiko
import os

paramiko.util.log_to_file('logfile.log')

host = "ftp.myserver.com"
port = 22
transport = paramiko.Transport((host, port))
password = "mypassword"
username = "myusername"
folder = "/Home/foldername/Automation_DKC_"

transport.connect(username=username, password=password)

sftp = paramiko.SFTPClient.from_transport(transport)

print("Successfully Connected to SFTP")

latest = 0
latestfile = None

for fileattr in sftp.listdir_attr():
    if fileattr.filename.startswith('Automation_DKC') and fileattr.st_mtime > latest:
        latest = fileattr.st_mtime
        latestfile = fileattr.filename


filepath = '/Home/foldername/' +latestfile
localpath = '/app/www/html/project/dkc.csv'
sftp.get(filepath, localpath)

sftp.close()
transport.close()

请协助我解决这个问题。谢谢。

程序运行正常,实际上是服务器防火墙问题,无法连接。我的 IT 团队解决了这个问题。