Ruby &引用;协商超时“;使用em ssh并行连接多个主机时
我使用em-ssh-gem(EventMachine的netssh适配器)在多个远程主机上执行一些shell命令。命令在第一台主机上成功执行,但在其他主机上失败,它会抱怨“EventMachine::Ssh::ConnectionTerminated” 和“EventMachine::Ssh::NegotiationTimeout”。 这些主机似乎在争夺某些东西,可能是端口?有人能解释一下吗Ruby &引用;协商超时“;使用em ssh并行连接多个主机时,ruby,ssh,eventmachine,Ruby,Ssh,Eventmachine,我使用em-ssh-gem(EventMachine的netssh适配器)在多个远程主机上执行一些shell命令。命令在第一台主机上成功执行,但在其他主机上失败,它会抱怨“EventMachine::Ssh::ConnectionTerminated” 和“EventMachine::Ssh::NegotiationTimeout”。 这些主机似乎在争夺某些东西,可能是端口?有人能解释一下吗 def em_ssh_connection(ssh_host,ssh_user,ssh_password
def em_ssh_connection(ssh_host,ssh_user,ssh_password,&cb)
EM.run do
EM::Ssh.start("#{ssh_host}","#{ssh_user}",:password => "#{ssh_password}") do|connection|
connection.errback do |err|
@logger.info "#{err} (#{err.class})"
EM.stop
end
connection.callback do |ssh|
@logger.info "succcessfully connected with #{ssh_host},#{ssh_user},#{ssh_password}"
yield ssh
ssh.close
EM.stop
end
end
end
end
def search_servers(ssh_host,ssh_user,ssh_password)
em_ssh_connection(ssh_host,ssh_user,ssh_password) {|ssh|
command = 'sed -n \'/.*server s1 [0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}/=\' '+"#{@haproxy_conf}"
myarray = em_ssh_exec(ssh,command)
if myarray[2] == 0
if myarray[0] != ""
@logger.info "all tcp servers(lines): #{myarray[0]}"
lines = myarray[0].split("\n")
if lines.length >0
start_line = lines[0].to_i
stop_line = lines[lines.length-1].to_i
@logger.info "start_line:#{start_line},stop_line:#{stop_line}"
delete_tcp_upstream(ssh,start_line,stop_line)
else
end
else
@logger.info "the stream field in proxy file is empty"
end
else
@logger.info "search all servers command failed:#{myarray[1]}"
end
}
end
def clear_haproxy(&cb)
search_servers(@ssh_host1,@ssh_user1,@ssh_password1)
search_servers(@ssh_host2,@ssh_user2,@ssh_password2)
cb.call
end
你真的应该为你的问题提供更多的细节。确切的错误是什么?能否显示导致此错误的代码以及错误的完整堆栈跟踪?代码已附加,谢谢!