From: Robert Klemme Date: 2011-11-17T00:21:27+09:00 Subject: Re: SSH hangs for 30 sec on AIX On Wed, Nov 16, 2011 at 1:41 PM, Claus Folke Brobak wrote: > Environment: > > - AIX 6.1 > > - Java: >  java version "1.6.0" >  Java(TM) SE Runtime Environment (build pap3260sr9fp1-20110208_03(SR9 > FP1)) >  IBM J9 VM (build 2.4, JRE 1.6.0 IBM J9 2.4 AIX ppc-32 > jvmap3260sr9-20110203_74623 (JIT enabled, AOT enabled) >  J9VM - 20110203_074623 >  JIT  - r9_20101028_17488ifx3 >  GC   - 20101027_AA) >  JCL  - 20110203_01 > > - jruby 1.6.5 (ruby-1.8.7-p330) (2011-10-25 9dcd388) (IBM J9 VM 1.6.0) > [AIX-ppc-java] > > - Gems: >  - bouncy-castle-java (1.5.0146.1) >  - jruby-openssl (0.7.4) >  - net-ssh (2.2.1) > > Code: >    require 'rubygems' >    require 'net/ssh' >    host = 'xxxxxxx.xxxxxx.xxx' >    username = 'xxxx' >    Net::SSH.start(host, username, :verbose => :debug) do |ssh| >      puts ssh.exec!("hostname") >      puts ssh.exec!("ls") >    end > > When running this program it hangs for 30 seconds at four points, as I > have shown below. Note that I have omitted a number of lines. > >    - >    - >    D, [2011-11-16T11:53:11.477000 #1213352018] DEBUG -- tcpsocket[7d4]: > received packet nr 6 type 52 len 12 >    D, [2011-11-16T11:53:11.478000 #1213352018] DEBUG -- > net.ssh.authentication.methods.publickey[7dc]: publickey succeeded > (2d:32:27:ed:60:c8:28:28:77:50:7d:40:d7:83:ef:4b) >    D, [2011-11-16T11:53:11.482000 #1213352018] DEBUG -- tcpsocket[7d4]: > queueing packet nr 7 type 90 len 44 >    <<< Hangs for 30 seconds, then continues >>> >    - >    - >    D, [2011-11-16T11:53:41.573000 #1213352018] DEBUG -- tcpsocket[7d4]: > received packet nr 8 type 91 len 28 >    I, [2011-11-16T11:53:41.577000 #1213352018]  INFO -- > net.ssh.connection.session[7de]: channel_open_confirmation: 0 0 0 32768 >    I, [2011-11-16T11:53:41.579000 #1213352018]  INFO -- > net.ssh.connection.channel[7e0]: sending channel request "exec" >    D, [2011-11-16T11:53:41.586000 #1213352018] DEBUG -- tcpsocket[7d4]: > queueing packet nr 9 type 98 len 44 >    <<< Hangs for 30 seconds, then continues >>> >    - >    - >    D, [2011-11-16T11:54:11.556000 #1213352018] DEBUG -- tcpsocket[7d4]: > received packet nr 15 type 97 len 12 >    I, [2011-11-16T11:54:11.558000 #1213352018]  INFO -- > net.ssh.connection.session[7de]: channel_close: 0 >    D, [2011-11-16T11:54:11.560000 #1213352018] DEBUG -- tcpsocket[7d4]: > queueing packet nr 11 type 97 len 28 >    <<< Output from hostname command >>> >    D, [2011-11-16T11:54:11.563000 #1213352018] DEBUG -- tcpsocket[7d4]: > queueing packet nr 12 type 90 len 44 >    <<< Hangs for 30 seconds, then continues >>> >    - >    - >    D, [2011-11-16T11:54:41.510000 #1213352018] DEBUG -- tcpsocket[7d4]: > received packet nr 17 type 91 len 28 >    I, [2011-11-16T11:54:41.514000 #1213352018]  INFO -- > net.ssh.connection.session[7de]: channel_open_confirmation: 1 1 0 32768 >    I, [2011-11-16T11:54:41.515000 #1213352018]  INFO -- > net.ssh.connection.channel[7e2]: sending channel request "exec" >    D, [2011-11-16T11:54:41.518000 #1213352018] DEBUG -- tcpsocket[7d4]: > queueing packet nr 13 type 98 len 28 >    <<< Hangs for 30 seconds, then continues >>> >    - >    - >    <<< Output from ls command >>> >    I, [2011-11-16T11:55:11.549000 #1213352018]  INFO -- > net.ssh.connection.session[7de]: closing remaining channels (0 open) > > If I switch to Java 5 on AIX instead, the program runs without problems. > Also, I can run the same program without problems on Windows XP and Java > 6 (from Oracle). > > Any help in solving this problem would be much appreciated. Hmm... The first thing that comes to mind is "reverse lookups". see http://rubydoc.info/stdlib/socket/1.9.3/IPSocket#addr-instance_method You could try strace or truss to see what is different in socket handling between the two versions of Java which show a difference. Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/