我正在为我的服务器编写一个 ssl 客户端,它使用 python 和 pyqt4 扭曲,我使用 QTReactor 在 PYQT 中扭曲,但是当我运行代码时出现错误
AttributeError: 'NoneType' object has no attribute 'connectSSL'
我的初始代码是这样的
from OpenSSL import SSL
import sys
from twisted.internet.protocol import ClientFactory
from twisted.protocols.basic import LineReceiver
from twisted.internet import ssl
import qt4reactor
app = QtGui.QApplication(sys.argv)
reactor=qt4reactor.install()
main()
myapp = MainForm()
myapp.show()
reactor.runReturn()
sys.exit(app.exec_())
def main():
factory = ClientFactory()
reactor.connectSSL('localhost', 8080, factory, ssl.ClientContextFactory())
try:
reactor.run()
except KeyboardInterrupt:
reactor.stop()
我运行它时的错误:
Traceback (most recent call last):
File "client.py", line 51, in <module>
main()
File "client.py", line 40, in main
reactor.connectSSL('localhost', 8080, factory, ssl.ClientContextFactory())
AttributeError: 'NoneType' object has no attribute 'connectSSL'