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

NIOSSHClient gets stucked #86

Open
vladimir-aubrecht opened this issue May 30, 2021 · 11 comments
Open

NIOSSHClient gets stucked #86

vladimir-aubrecht opened this issue May 30, 2021 · 11 comments

Comments

@vladimir-aubrecht
Copy link

Problem

When testing NIOSSHClient, I am always getting stucked indefinitely on childChannel wait() method. Could somebody help me understand what is the problem?

Findings

  • promise.FutureResult was created successfully, but my guess is, it was never met.
  • ExampleExecHandler was never activated and command was never executed.

Setup

  • Testing on M1 Macbook Pro with latest MacOS & XCode
@Elektronenhirn108
Copy link

@vladimir-aubrecht Same problem here. Did you find a solution?
It appears that createChannel doesn't do anything inside.

@sarensw
Copy link

sarensw commented Feb 14, 2022

I'm getting an exception exactly there. Do you also get an exception? Or is it just endlessly waiting?

NIOSSHClient/main.swift:97: Fatal error: 'try!' expression unexpectedly raised an error: NIOCore.ChannelError.eof
2022-02-14 11:14:55.954988+0100 NIOSSHClient[89883:1868853] NIOSSHClient/main.swift:97: Fatal error: 'try!' expression unexpectedly raised an error: NIOCore.ChannelError.eof

@Lukasa
Copy link
Collaborator

Lukasa commented Feb 15, 2022

createChannel requires an active SSH connection to be open and running: if it isn't, it won't be able to do anything. Please make sure your connection is created.

@sarensw You seem to have another issue, which is that you're creating a channel when the connection has been torn down already.

@sarensw
Copy link

sarensw commented Feb 15, 2022

@Lukasa thanks for the info. I'll create another ticket then as I am using the Swift SSH example client without any line changed.

@sarensw
Copy link

sarensw commented Feb 25, 2022

@Lukasa Now I also stumbled into the same situation as described by the author of this ticket.

The following section is basically taken from the client example, with some prints added.

// Wait for the connection to close
print("closing")
try! childChannel.closeFuture.wait()
print("child channel closed")
let exitStatus = try! exitStatusPromise.futureResult.wait()
print("exist status promise awaited")
try! channel.close().wait()
print("all closed")
print(exitStatus)

closing is printed, but child channel closed is never reached as it gets stuck on try! childChannel.closeFuture.wait().

The command that I provide is executed correctly on the remotely connected system, just as I would expect. So the channel seems to be successfully created.

Do you have any idea? Is there any way that I can analyse this further?

@sarensw
Copy link

sarensw commented Feb 28, 2022

@Lukasa , so I've been adding print() pretty much everywhere in the code now. It turns out that self.context?.close(...) in GlueHandler never returns

private func partnerWriteEOF() {
    print("func partnerWriteEOF")
    self.context?.close(mode: .output, promise: nil)
    print("func partnerWriteEOF closed")
}

So func partnerWriteEOF is still printed out, but func partnerWriteEOF closed not. This is where the client basically stops working, waiting for close() to return.

@Lukasa
Copy link
Collaborator

Lukasa commented Mar 7, 2022

That is unlikely to be possible: close should be asynchronous, and should not block. Can you use lldb to print the call stack after this point?

@daugust7
Copy link

I am having what appears to be the same problem. Any updates @sarensw?

@daugust7
Copy link

@sarensw
Copy link

sarensw commented Mar 25, 2022

@daugust7 no update yet. I want to take some time again next week to "print the call stack after this point" using lldb. As I'm still a Swift beginner, this might take a while 😄 .

You are right with the link in the forum. The question in the forum is actually also from me. So it is related 👍

@JiangYulin
Copy link

Any update on this issue?

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

6 participants