[erlang-questions] erlang gen_tcp:connect/3 not working with rpc:call/4, anyone knows why?

Raimo Niskanen <>
Fri Sep 23 11:40:18 CEST 2011


On Wed, Sep 21, 2011 at 01:48:57PM -0500, Allen Kim wrote:
> I don't see any difference from outputs from the following commands.
> It both uses native lookup.
> Anyway, it is not a big deal since I do not use Mac for staging nor production. it's only for development.

Debugging hints: run without the -detached flag and debug the native resolver's problems:

$ ssh 
$ erl -name 
Erlang R14B03 (erts-5.8.4) [source] [64-bit] [smp:8:8] [rq:8] [async-threads:0] [hipe] [kernel-poll:false]

Eshell V5.8.4  (abort with ^G)
()1> inet_gethost_native:control({debug_level,9}).
inet_gethost[3930] (DEBUG):debug_level = 9
ok
()2> inet:gethostbyname("www.google.com").
inet_gethost[3930] (DEBUG):Saved domainname .google.com.
inet_gethost[3930] (DEBUG):Created worker[3948] with fd 3
inet_gethost[3930] (DEBUG):Saved domainname .google.com.
inet_gethost[3948] (DEBUG):Worker got request, op = 1, proto = 1, data = www.google.com.
inet_gethost[3948] (DEBUG):Starting gethostbyname(www.google.com)
inet_gethost[3948] (DEBUG):gethostbyname OK
{ok,{hostent,"www.l.google.com",
             ["www.google.com"],
             inet,4,
             [{173,194,32,52},
              {173,194,32,48},
              {173,194,32,49},
              {173,194,32,50},
              {173,194,32,51}]}}
()3> 


> 
> However, I hope it's better to be consistent on all kind of *nix environment.
> Or, it could be me only.
> 
> Any Mac user who what to test this?
> 
> $ssh   'erl -name  -detached -setcookie loadtest'
> $erl -name  -setcookie loadtest
> > net_adm:ping('').
> > gen_tcp:connect("www.google.com",80,[]).
> >rpc:call('',gen_tcp,connect,["www.google.com",80,[]]).
> 
> 
> ()6> io:format("~p~n",[ets:tab2list(inet_db)]).
> [{res_resolv_conf_info,undefined},
>  {res_hosts_file_info,undefined},
>  {res_domain,"local"},
>  {res_hosts_file_tm,0},
>  {res_resolv_conf_tm,0},
>  {cache_refresh_interval,3600000},
>  {socks5_noproxy,[]},
>  {res_retry,3},
>  {res_search,["local"]},
>  {res_resolv_conf,"/etc/resolv.conf"},
>  {res_inet6,false},
>  {res_recurse,true},
>  {hostname,"allen"},
>  {res_udp_payload_size,1280},
>  {cache_size,100},
>  {sctp_module,inet_sctp},
>  {udp_module,inet_udp},
>  {tcp_module,inet_tcp},
>  {res_hosts_file,"/etc/hosts"},
>  {res_id,0},
>  {socks5_port,1080},
>  {res_timeout,2000},
>  {res_edns,false},
>  {res_alt_ns,[]},
>  {socks5_methods,[none]},
>  {res_ns,[{{192,168,14,10},53},{{192,168,24,10},53}]},
>  {res_usevc,false},
>  {socks5_server,[]},
>  {res_lookup,[native]}]
> ok
> ()7> io:format("~p~n",[rpc:call('', ets,tab2list,[inet_db])]).
> [{res_resolv_conf_info,undefined},
>  {res_hosts_file_info,undefined},
>  {res_domain,"local"},
>  {res_hosts_file_tm,0},
>  {res_resolv_conf_tm,0},
>  {cache_refresh_interval,3600000},
>  {socks5_noproxy,[]},
>  {res_retry,3},
>  {res_search,["local"]},
>  {res_resolv_conf,"/etc/resolv.conf"},
>  {res_inet6,false},
>  {res_recurse,true},
>  {hostname,"allen"},
>  {res_udp_payload_size,1280},
>  {cache_size,100},
>  {sctp_module,inet_sctp},
>  {udp_module,inet_udp},
>  {tcp_module,inet_tcp},
>  {res_hosts_file,"/etc/hosts"},
>  {res_id,0},
>  {socks5_port,1080},
>  {res_timeout,2000},
>  {res_edns,false},
>  {res_alt_ns,[]},
>  {socks5_methods,[none]},
>  {res_ns,[{{192,168,14,10},53},{{192,168,24,10},53}]},
>  {res_usevc,false},
>  {socks5_server,[]},
>  {res_lookup,[native]}]
> ok
> 
> 
> 
> From: Magnus Klaar <<mailto:>>
> Date: Wed, 21 Sep 2011 13:18:51 -0500
> To: Allen Kim <<mailto:>>
> Cc: Kaiduan Xie <<mailto:>>, "<mailto:>" <<mailto:>>
> Subject: Re: [erlang-questions] erlang gen_tcp:connect/3 not working with rpc:call/4, anyone knows why?
> 
> Hi!
> 
> The Erlang VM provides multiple strategies for name lookups, among them is a native lookup mechamism using getaddrinfo and
> an erlang client implemented by the inet_res module.
> 
> The contents of the inet_db table on the detached node may also be worth looking into, does it differ? which strategy does it use?. You can access it using:
> 
> rpc:call('<mailto:>', ets,tab2list,[inet_db]).
> 
> You may also want to look into the mDNSResponder daemon that OSX uses as a system-wide resolver. this daemon appears to
> be an alternative to the nscd deamon found on GNU/Linux systems. Applications are expected to perform lookups against this daemon.
> 
> MVH Magnus
> 
> On Wed, Sep 21, 2011 at 7:03 PM, Allen Kim <<mailto:>> wrote:
> It IS Mac OS X issue, definitely.
> I ran it from CentOS box, and it works fine.
> Don't know why it does not work on Mac OS X though.
> 
> 
> On 11-09-21 12:35 PM, "Allen Kim" <<mailto:>> wrote:
> 
> >$cat /etc/resolv.conf
> >#
> ># Mac OS X Notice
> >#
> ># This file is not used by the host name and address resolution
> ># or the DNS query routing mechanisms used by most processes on
> ># this Mac OS X system.
> >#
> ># This file is automatically generated.
> >#
> >nameserver 192.168.14.10nameserver 192.168.24.10
> >
> >
> 

> _______________________________________________
> erlang-questions mailing list
> 
> http://erlang.org/mailman/listinfo/erlang-questions


-- 

/ Raimo Niskanen, Erlang/OTP, Ericsson AB



More information about the erlang-questions mailing list