plumbum icon indicating copy to clipboard operation
plumbum copied to clipboard

Unable to use SshMachine in a Thread in a Django View running on Apache2 with HTTPS

Open melvyniandrag opened this issue 6 years ago • 2 comments

I'm not sure if this deserves a fix, or if I simply need a configuration change. Not a web developer, just a dabbler who's slapping front ends on interesting(subjective) linux apps. So I might be overlooking an obvious apache2 config step.

This code runs fine in a stand-alone python script:

from rpyc.utils.zerodeploy import DeployedServer
from plumbum import SshMachine
import threading

class T(object):
    def __init__(self):
        thread = threading.Thread(target=self.run, args=())
        thread.daemon = False
        thread.start()

    def run( self ):
        host = "mystery"
        mach = SshMachine( host, user="confidential", keyfile="secret")
        server = DeployedServer(mach )
        conn1 = server.classic_connect()
        print(conn1.modules.sys.platform)
        server.close()

print("before thread")
t = T()
print("after thread")

but when it's incorporated into a Django view, running on Apache2 with HTTPS, I get the error

plumbum.machines.session.SSHCommsError: No communication channel detected. Does the remote exist?

The issue I suppose is with the pipe.readline() in here. Going to edit the files and see what the return code is. My guess is this has something to do with the way apache handles stdout/stderr. Will try to stick this in an an app running without apache2 and without https and see what happens. Update soon.

I had been using paramiko for my connection without problems, so there is a solution to this issue I guess. Just have to see if it's worth implementing something or not.

melvyniandrag avatar Oct 18 '18 19:10 melvyniandrag

Issue is apache or https configuration. Looking into apache2 config now to see if it's reasonable to patch and PR. probably not.

melvyniandrag avatar Oct 18 '18 21:10 melvyniandrag

Abandoning this for now. Hope to circle back in the near future.

melvyniandrag avatar Oct 21 '18 02:10 melvyniandrag