Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

scala-ssh execute sometimes hangs even though the remote command succeeds #39

Open
nextdude opened this issue Jul 22, 2018 · 2 comments

Comments

@nextdude
Copy link

I've got two virtually identical scripts that I'm running on a remote server, both of which succeed and complete on the remote server, but one of which hangs (that is, its scala-ssh session only terminates after command timeout). I'm executing them via this scala code:

def remoteRequest(req: SlackRequest): Either[Throwable, SlackResponse] = for {
    server <- findServer(req)
    studyOpt <- findStudy(req, server.id)
    commandInput <- getCommandInput(req)
    commandResult <- {
      val domain = studyOpt.map(_.domain).getOrElse("")
      SSH(server.host, HostResourceConfig()) {
        client =>
          for {
            result <- {
              val command = Command(s"bash -s -- $domain ${req.args.mkString(" ")}", commandInput)
              client.exec(command)
            }
          } yield result
      }.toEither
    }
    response <- processRemoteResult(req, commandResult)
  } yield response

Here's the host resource config:

# scala-ssh host config file
login-type = password
username = exxxxxxxxxxr
password = blahblahblah
fingerprint = any
command-timeout = 30000

I've attached two scripts, along with their logs. The lock_user.sh.txt script runs successfully on the remote server and scala-ssh returns normally after the command finishes. The unlock_user.sh.txt script also runs successfully on the remote server but scala-ssh hangs and only terminates when the command timeout is triggered. I've verified the unlock script succeeds, both by running it manually via the command line and because the db update succeeds.

lock_user.sh.txt
lock-ok.log
unlock_user.sh.txt
unlock-fail.log

Can anyone explain what's going on here? I can't tell what's different between these two cases. I've also changed the order of their execution, to no avail (that is, same result...lock always succeeds, unlock always hangs until timeout). I've got other scripts, some of which work and some of which hang even though all succeed in executing and terminating normally on the remote server, so I don't think this has anything to do with the scripts themselves.

Thanks for any insights.

@Openpalm
Copy link

Openpalm commented Sep 30, 2019

i think these here are all connected, it sounds at least, to have an underlying common issue;

#36
#22
#21
#20

i hope to have some free time and look at this as a Christmas project.
doing some recon and collecting possible connected tickets,
apologies for spam.

@Openpalm
Copy link

Thanks for your input!
A better async stream-based API would indeed be great.
Maybe something based on reactive streams (www.reactive-streams.org).

Originally posted by @sirthias in #22 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants