em-ssh icon indicating copy to clipboard operation
em-ssh copied to clipboard

em-ssh-shell fails to start shell without error

Open darkskiez opened this issue 13 years ago • 6 comments

Not sure whats happening yet, but my block inside EM::Ssh::Shell.new never gets evaluated, and no errors are raised

I can simulate this easily by connecting 50 times concurrently

darkskiez avatar Apr 24 '12 10:04 darkskiez

Can you post some example code please?

Sent from my iPhone

On 2012/04/24, at 19:18, Mark [email protected] wrote:

Not sure whats happening yet, but my block inside EM::Ssh::Shell.new never gets evaluated, and no errors are raised

I can simulate this easily by connecting 50 times concurrently


Reply to this email directly or view it on GitHub: https://github.com/simulacre/em-ssh/issues/5

gruis avatar Apr 24 '12 10:04 gruis

EM.run {
  EM.error_handler do |e| 
    puts " **** ERROR #{e.message}"
    puts e.backtrace.join "\n" 
  end
  started=0

  (1..30).each do
    EM::Ssh::Shell.new("localhost", "emtest", "emdemo") do |shell|
      started+=1    
      shell.on(:error) do |e|
        puts "Shell error :( #{e}"
      end
      shell.on(:closed) do |e|
        puts "Shell close :( #{e}"
      end
    end
  end

  EventMachine::PeriodicTimer.new(1) do
    puts "We have #{started} connections"
  end
}

On my machine stared goes to 10, but never get any exceptions or errors.

darkskiez avatar Apr 24 '12 10:04 darkskiez

I found the reason for the 10 limit is the sshd_config default for MaxStartups is 10 but it doesn't explain the lack of errors.

darkskiez avatar Apr 25 '12 15:04 darkskiez

I'd put my money on this actually being the thread pool in EM (I believe it defaults to 20)...

Also, opening 30+ requests is quite inefficient, I'd suggest looking into using EM's work and request pooling:

https://github.com/eventmachine/eventmachine/blob/master/lib/em/pool.rb#L9-38

seryl avatar Sep 21 '12 01:09 seryl

root 2106 1 0 Aug13 ? 00:00:28 /usr/sbin/sshd root 19326 2106 0 11:02 ? 00:00:00 sshd: root@pts/0 root 24137 2106 0 18:01 ? 00:00:00 sshd: root@pts/1 root 24154 2106 0 18:01 ? 00:00:00 sshd: root@pts/2 root 24155 2106 0 18:01 ? 00:00:00 sshd: root@pts/3 root 24156 2106 0 18:01 ? 00:00:00 sshd: root@pts/4 root 24157 2106 0 18:01 ? 00:00:00 sshd: root@pts/5 root 24158 2106 0 18:01 ? 00:00:00 sshd: root@pts/6 root 24159 2106 0 18:01 ? 00:00:00 sshd: root@pts/7 root 24160 2106 0 18:01 ? 00:00:00 sshd: root@pts/9 root 24161 2106 0 18:01 ? 00:00:00 sshd: root@pts/8 root 24162 2106 0 18:01 ? 00:00:00 sshd: root@pts/10 root 24163 2106 0 18:01 ? 00:00:00 sshd: root@pts/11 root 24305 24139 0 18:01 pts/1 00:00:00 grep ssh [root ~]# ps -ef | grep ssh root 2106 1 0 Aug13 ? 00:00:28 /usr/sbin/sshd root 19326 2106 0 11:02 ? 00:00:00 sshd: root@pts/0 root 24137 2106 0 18:01 ? 00:00:00 sshd: root@pts/1 root 24307 24139 0 18:01 pts/1 00:00:00 grep ssh

I was incorrect. Tested the pool, not the case.

It's the max_startups as described above.

However, this still should be handled in a work queue, 10 simultaneous connections is plenty.

seryl avatar Sep 21 '12 01:09 seryl

Folks, do you still see this issue?

kt97679 avatar Jul 22 '18 16:07 kt97679