Note that there are some explanatory texts on larger screens.

plurals
  1. POTwisted deferred not callable after connection failure
    primarykey
    data
    text
    <p>Having my client factory here:</p> <pre><code>import logging, traceback from twisted.internet.protocol import ClientFactory from twisted.internet import defer, reactor, ssl from twisted.application import service from protocols.smpp.protocol import SMPPClientProtocol class SMPPClientFactory(ClientFactory): protocol = SMPPClientProtocol def __init__(self, config): self.config = config def getConfig(self): return self.config def clientConnectionFailed(self, connector, reason): print "clientConnectionFailed" self.connectDeferred.errback(reason) def clientConnectionLost(self, connector, reason): print "clientConnectionLost" def connect(self): self.connectDeferred = defer.Deferred() factory = SMPPClientFactory(self.config, self.msgHandler) self.log.warning('Establishing TCP connection to %s:%d' % (self.config.host, self.config.port)) reactor.connectTCP(self.config.host, self.config.port, factory) return self.connectDeferred </code></pre> <p>And it's launching code here:</p> <pre><code>import logging, traceback from twisted.internet import reactor, defer from protocols.smpp.configs import SMPPClientConfig from protocols.smpp.smpp_operations import SMPPOperationFactory from testbed.client import SMPPClientFactory class SMPP(object): def __init__(self, config=None): if config is None: config = SMPPClientConfig() self.config = config self.opFactory = SMPPOperationFactory(config) def run(self): try: #Bind SMPPClientFactory(self.config, self.handleMsg).connect().addErrback(self.connectFailed) except Exception, e: print "ERROR: %s" % str(e) def connectFailed(self, reason): print "Connection failed %s" % str(reason) def handleMsg(self, smpp, pdu): pass if __name__ == '__main__': config = SMPPClientConfig(host='127.0.0.1', port=2775, username='smppclient1', password='password', log_level=logging.DEBUG) logging.basicConfig(level=config.log_level, filename=config.log_file, format=config.log_format,datefmt=config.log_dateformat) SMPP(config).run() reactor.run() </code></pre> <p>When the connection is failing (the remote server is down), i get factory's clientConnectionFailed called but it is strangely getting a "exceptions.AttributeError: SMPPClientFactory instance has no attribute 'connectDeferred'".</p> <p>I need to call the errback when the connection fails, it seems there's something missing when dealing with deferreds ..</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload