sockets - Ruby TCPServer always delay on dns reverse lookup? - how to disable? -


i created tcpserver ruby gserver.

everytime connect remotly server, takes 2-4 seconds until connection established.

this happen if connect remote machine.

connection same machine has running service send immidiate response.

for connection on same machine there no difference if connect via localhost or via machines ip.


i think delay depends on reverse lookup can not localize why.

in gserver.rb line 263

client = @tcpserver.accept 

here delay occurs, not know in method.


i added machines used during tests local hosts file. changed nothing.

same happens when using webrick, tried set also

basicsocket.do_not_reverse_lookup = true 

as direct on resulting server socket

socket.do_not_reverse_lookup = true 

as on client connection socket

client.do_not_reverse_lookup = true 

but changed nothing on delay.


whenever connection established, values of remote_host , remote_ip resolved , defined in hosts file.


i tried running ruby 2.2.1 on ubuntu 14.04 ruby 1.9.3 running debian wheezy.

same behavior - (long) delay on connecting service.

q: how fix / disable lookup on tcpserver?

the problem depends on client machine run on mac osx mav.

the used telnet client tries open ipv6 connection , afterwards ipv4.

to solve delay, open connection with

telnet -4 my-server 3333 

i have build small connect echo servive can check resolves , timings.

if change no_reverse_lookup ips or addresses , if not resolveable, different response times.

require 'socket'  no_reverse_lookup = true connect_port = 3333  puts "#{time.now} starting service on port: #{connect_port}"  # full hell - test if meets want tcpserver.do_not_reverse_lookup = no_reverse_lookup basicsocket.do_not_reverse_lookup = no_reverse_lookup socket.do_not_reverse_lookup = no_reverse_lookup  srv = tcpserver.open(connect_port)  puts "#{time.now} waiting client"  client = srv.accept  puts "#{time.now} client connected"  client.do_not_reverse_lookup = no_reverse_lookup  client.print "hello connected\n"  # in case disabled reverse lookup, should receive ip adresses  puts "#{time.now} getting server address infos"   puts "server info:" puts no_reverse_lookup ? client.addr(:numeric) : client.addr(:hostname)  puts ""  puts "#{time.now} getting remote client infos"  puts "remote info:" puts no_reverse_lookup ? client.peeraddr(:numeric) : client.peeraddr(:hostname)  ###  puts "#{time.now} closing connection"  client.close  puts "#{time.now} end" 

thanks drbrain #ruby-lang irc pointing me ipv6 problem.


Comments

Popular posts from this blog

google api - Incomplete response from Gmail API threads.list -

Installing Android SQLite Asset Helper -

Qt Creator - Searching files with Locator including folder -