fab-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Fab-user] Connection timeout through a gateway


From: Erik Dahl
Subject: [Fab-user] Connection timeout through a gateway
Date: Tue, 14 May 2013 16:43:31 -0400

I'm using fabric through a gateway to configure an EC2 instance.  I spin the 
instance up through the AWS API and wait for it to come on line by polling the 
API.  The instance comes "on-line" before the OS is booted though so my code 
that uses fabric starts trying to connect before ssh is up.  No big deal just 
increase the connection_attempts but alas this doesn't work when going through 
a gateway.  

The problem is in network.py direct_tcpip which throws 
paramiko.ChannelException when it times out and this isn't caught anywhere.  
Not sure what the best solution is.  I hacked the following to get it working.  
My sleep call isn't really a timeout but I don't see where I can put a timeout 
on opening a channel on an existing transport.

def direct_tcpip(client, host, port):
    trans = client.get_transport()
    #trans.settimeout(30)
    import time
    from state import env
    import paramiko 
    tries = env.connection_attempts
    while tries:
        try:
            return trans.open_channel(
                'direct-tcpip',
                (host, int(port)),
                ('', 0)
            )
        except paramiko.ChannelException, e:
            tries -= 1
            time.sleep(env.timeout)

Thoughts?

-EAD





reply via email to

[Prev in Thread] Current Thread [Next in Thread]