ikhaliq15 ikhaliq15 - 1 year ago 231
Python Question

Trying to use twisted on OSX

I recently found the Twisted python library and was trying to set it up with a test script.

from twisted.internet.protocol import Protocol, Factory
from twisted.internet import reactor

class Pong(Protocol):
def connectionMade(self):
self.transport.write("HTTP/1.0 200 OK\r\nContent-Length: 5\r\n\r\nPong!\r\n")
self.transport.loseConnection()

# Start the reactor
factory = Factory()
factory.protocol = Pong
reactor.listenTCP(8000, factory)
reactor.run()


When i run the above (I am using python 2.7.9 btw) in Terminal, I get an error. The last line of the error is below. If you need the rest, I can post it as well.

AttributeError: 'module' object has no attribute 'OP_NO_TLSv1_1'

Answer Source

OP_NO_TLSv1_1 is an attribute in pyOpenSSL. This means your version of pyOpenSSL is too old. pip install -U pyopenssl or pip install twisted[tls] should resolve this, but I'd highly recommend doing all of this in a virtual environment if you aren't already.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download