gpt4 book ai didi

在 IPhone/ATT 上进行网络共享时出现 Python FTP SSL 错误

转载 作者:太空宇宙 更新时间:2023-11-03 14:10:47 25 4
gpt4 key购买 nike

我有一些简单的 ftps 代码,当通过 WIFI 连接时,它可以在我的笔记本电脑上运行。但是,如果我使用我的 ATT iPhone 网络共享功能,代码将不再在我的笔记本电脑上运行,并引发以下错误:

*cmd* 'AUTH TLS'
*put* 'AUTH TLS\r\n'
*get* '234 Proceed with negotiation.\r\n'
*resp* '234 Proceed with negotiation.'
Traceback (most recent call last):
File "/Users/n/anaconda/lib/python2.7/ftplib.py", line 669, in login
self.auth()
File "/Users/n/anaconda/lib/python2.7/ftplib.py", line 681, in auth
server_hostname=self.host)
File "/Users/n/anaconda/lib/python2.7/ssl.py", line 352, in wrap_socket
_context=self)
File "/Users/n/anaconda/lib/python2.7/ssl.py", line 579, in __init__
self.do_handshake()
File "/Users/n/anaconda/lib/python2.7/ssl.py", line 808, in do_handshake
self._sslobj.do_handshake()
ssl.SSLEOFError: EOF occurred in violation of protocol (_ssl.c:590)
[Finished in 52.4s with exit code 1]

如何在使用网络共享时让以下示例正常工作?

from ftplib import FTP_TLS

url = 'url.com'
username = 'guest'
password = 'password'

ftps = FTP_TLS(url)
ftps.login(username, password) # login anonymously before securing control channel
ftps.prot_p() # switch to secure data connection

print ftps.nlst()

ftps.quit()

我也试过包括the SSL monkey patch from this stackoverflow answer没有成功。

import ssl 
ssl._create_default_https_context = ssl._create_unverified_context

最佳答案

先把debuglevel设置成2打印出更多信息,再对比一下WiFi和AT&T下的区别,我现在能想到的是网络从断开的接口(interface)发起连接,所以你可以尝试禁用它们并让 AT&T 处于事件状态。

关于在 IPhone/ATT 上进行网络共享时出现 Python FTP SSL 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30904084/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com