久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

Ftplib ConnectionRefusedError:[Errno 111] 連接被拒絕(pyt

Ftplib ConnectionRefusedError: [Errno 111] Connection refused (python 3.5)(Ftplib ConnectionRefusedError:[Errno 111] 連接被拒絕(python 3.5))
本文介紹了Ftplib ConnectionRefusedError:[Errno 111] 連接被拒絕(python 3.5)的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我有一個應該連接到 FTP 的腳本

I have a script that should connect to a FTP

from ftplib import FTP

with FTP('IP') as ftp:
   ftp.login(user='my user', passwd='my password')
   ftp.cwd('/MY_DIR')
   ftp.dir()

我有一個錯誤:ConnectionRefusedError: [Errno 111] 連接被拒絕

ftp 是一個帶有 vsftpd 的 EC2

The ftp is an EC2 with vsftpd

pasv_enable=YES
pasv_min_port=1024
pasv_max_port=1048
pasv_address=IP
pasv_addr_resolve=YES

已經試過了:

代碼適用于其他有和沒有 TLS 的 FTP(托管在 1and1,OVH...)

Already tried :

The code work on other FTP with and without TLS (hosted on 1and1, OVH...)

我在 NodeJS 中嘗試過這個腳本

I tried this script in NodeJS

const ftpClient = require('ftp-client');

const client = new ftpClient({
   host: "IP",
   port: 21,
   user: "My user", // defaults to "anonymous"
   password: "My password" // defaults to "@anonymous"
});

client.connect(() => {

  client.download('/MY_DIR/file','/tmp/file', (res) => {
        console.log(res)
  })
});

工作得很好,所以我排除了防火墻問題

Works perfectly fine so I exclude a firewall problem

我已嘗試啟用 TLS

I have tried enable TLS

ssl_enable=YES
require_ssl_reuse=NO

那么sudo service vsftpd 重啟

then sudo service vsftpd restart

并使用
FTP_TLS 而不是 FTP但沒有工作

and use
FTP_TLS instead of FTP but did not work

我也嘗試通過設置禁用被動模式

Also I tried disable passive mode by setting

pasv_enable=NO

那么sudo service vsftpd restart

ftp.set_pasv(False)

也沒有用

推薦答案

解決方案

使用filezilla調試該方法后,發現盡管我們在/etc/vsftpd.conf中定義了,我們的FTP還是返回0.0.0.0

pasv_adress=IP

這篇文章幫助了我們:https://www.centos.org/論壇/viewtopic.php?t=52408

你必須評論

listen_ipv6=YES

并啟用

listen=YES

/etc/vsftpd.conf

如果您無法訪問 FTP 的 vsftpd.conf,您也可以覆蓋 ftplib 的類 FTP

Also you can override the ftplib's class FTP if you can't access to vsftpd.conf of the FTP

class CustomFTP(ftplib.FTP):

    def makepasv(self):
        if self.af == socket.AF_INET:
            host, port = ftplib.parse227(self.sendcmd('PASV'))
        else:
            host, port = ftplib.parse229(self.sendcmd('EPSV'), self.sock.getpeername())

        if '0.0.0.0' == host:
            """ this ip will be unroutable, we copy Filezilla and return the host instead """
            host = self.host
        return host, port

如果發送 '0.0.0.0' 則強制上一個主機

to force the previous host if '0.0.0.0' is send

這篇關于Ftplib ConnectionRefusedError:[Errno 111] 連接被拒絕(python 3.5)的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

Why I cannot make an insert to Python list?(為什么我不能插入 Python 列表?)
Insert a column at the beginning (leftmost end) of a DataFrame(在 DataFrame 的開頭(最左端)插入一列)
Python psycopg2 not inserting into postgresql table(Python psycopg2 沒有插入到 postgresql 表中)
list extend() to index, inserting list elements not only to the end(list extend() 索引,不僅將列表元素插入到末尾)
How to add element in Python to the end of list using list.insert?(如何使用 list.insert 將 Python 中的元素添加到列表末尾?)
TypeError: #39;float#39; object is not subscriptable(TypeError:“浮動對象不可下標)
主站蜘蛛池模板: 91麻豆精品国产91久久久资源速度 | 97视频在线观看免费 | 日韩中文字幕一区二区 | 日韩精品一区二区久久 | 成人免费日韩 | 四虎最新 | 九九色综合 | 久久亚洲一区二区三区四区 | 国内精品久久久久久 | 一区二区三区久久 | 欧美视频免费在线 | 黄色中文字幕 | 看a网站| 懂色av一区二区三区在线播放 | 日韩一区二区三区在线 | 亚洲一区二区国产 | 国产激情视频在线观看 | 91福利网 | 美女天堂av| 国产精品无码久久久久 | www.99re5.com| 欧美一级免费观看 | 亚洲福利一区二区 | 免费观看日韩av | 欧美乱大交xxxxx另类电影 | 神马久久久久久久久久 | 国产成人免费视频网站高清观看视频 | 国产精品久久久久久福利一牛影视 | 欧美精品一区二区三区视频 | 成人一级视频在线观看 | 伊人久久综合 | 激情一区 | 犬夜叉在线观看 | 欧美xxxx做受欧美 | 嫩草视频在线看 | 在线免费观看毛片 | 久久久久久国产精品免费免费狐狸 | 99爱免费 | 91大神xh98xh系列全部 | 波多野结衣先锋影音 | 欧美日韩久 |