I'm trying to implement an SSL client in Twisted that simply must connect to a socket and read binary data (specifically, tuples of data). I've gotten the code to a point where it seems to connect and disconnect successfully but no data is ever read from the socket.
class FeedbackHandler(LineReceiver):
MAX_LENGTH = 1024*1024
def connectionMade(self):
log.debug('feedbackHandler connectionMade')
def rawDataReceived(self, data):
log.debug('feedbackHandler rawDataReceived %s' % binascii.hexlify(data))
self.io.write(data)
def lineReceived(self, data):
log.debug('feedbackHandler lineReceived %s' % binascii.hexlify(data))
self.io.write(data)
def connectionLost(self, reason):
log.debug('feedbackHandler connectionLost %s' % reason)
self.deferred.callback(self.io.getValue())
io.close()
And the code that kicks it off:
factory = self.clientProtocolFactory() # a ClientFactory instance
context = self.getContextFactory(CERT_FILE) # a ClientContextFactory
reactor.connectSSL(server, port, factory, context)
However when it runs none of the received methods are called, regardless of setRawMode
. Is there just nothing to read from the server? connectionMade
and connectionLost
are called immediately when connecting and terminates with a ConnectionDone
error instance.