[Twisted-Python] SSH Forwading and Database Queries in same application

Kevin Klues klueska at gmail.com
Thu Jul 13 08:49:57 EDT 2006

I am trying to use twisted.conch.ssh to write an application that first sets
up an ssh connection that forwards port 5432 from an external server to my
local machine and then locally connect to a database running on the server
using that port.  I am able to write two separate applications that
accomplish what I want, but I am unable to integrate them into one.  Using
the two application approach, I can first start the application that sets up
my port forwarding and then start the application that connects to my
database.  I can then make queries using the second application and
everything seems to work just fine.  When integrating them into one
application I am still able to connect to the database, but I cannot run any
queries over it.  The queries hang indefinitely, and neither my callback nor
my errback functions that should run after the query has completed ever get
called.  My setup for implementing this is as follows....

I have introduced a deferred when setting up my port forwarding that gets
its callback only once the startFactory() event gets called for my class
derived from forwarding.SSHListenForwardingFactory.  The forwarding is setup
using the following code snippet.....

reactor.listenTCP(PORT, DatabaseForwardingFactory(self.conn, (LOCALHOST,
PORT), DatabaseClientForwardingChannel))


class DatabaseForwardingFactory(forwarding.SSHListenForwardingFactory):
class DatabaseClientForwardingChannel(

Does anyone have any idea why this might not be working?  I tried deferring
my query to a thread to see if this would help matters, but to no avail.
Any help at all would be appreciated.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://twistedmatrix.com/pipermail/twisted-python/attachments/20060713/ae735a4c/attachment.htm 

More information about the Twisted-Python mailing list