I am programming a ssl client to my server where it uses python twisted with pyqt4, I used QTReactor for twisted in PYQT but when I run the code there is an error
AttributeError: 'NoneType' object has no attribute 'connectSSL'
my initial code it like this
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()
the error when i run it:
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'
is the error message that you get when you try to invoke a method on
None.This line of code
is the only place where
reactoris assigned. The error message makes it clear thatreactoris being assigned the valueNone.All the web search hits that I can find on the topic follow this pattern:
and so I guess that’s how you are meant to do it. But I do confess to knowing precisely nothing about these frameworks.