Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Erlang ping node problem

Tags:

erlang

ping

I made in erlang shell:

1> node().
nonode@nohost

But

2> net_adm:ping(node()). 
pang

Why? What's problem? Why not pong?

Thank you.

like image 853
0xAX Avatar asked Apr 04 '11 13:04

0xAX


3 Answers

You didn't start Erlang with -name or -sname, which means that the distribution subsystem was not started. Try this:

$ erl -sname mynode
Erlang R14B02 (erts-5.8.3) [source] [64-bit] [smp:2:2] [rq:2] [async-threads:0] [hipe] [kernel-poll:false]

Eshell V5.8.3  (abort with ^G)
(mynode@foobar)1> node().
mynode@foobar
(mynode@foobar)2> net_adm:ping(node()).
pong
like image 168
legoscia Avatar answered Nov 19 '22 01:11

legoscia


I am not 100% sure, but You started erl without "-name" oder "-sname". I believe net_adm:ping/1 only works in a distributed mode.

like image 33
Boris Mühmer Avatar answered Nov 19 '22 02:11

Boris Mühmer


If you are trying to ping an erlang node but getting a pang.

Check the cookie with erlang:get_cookie() it will be some random string set the cookie of another node with erlang:set_cookie(Node, Cookie) or you could pass the cookie to the flag -setcookie

for example:

(foo@earth) erlang:get_cookie().
ASYRQKVNIFHWIIJQZIYN

(foo@earth) erlang:set_cookie(node(), 'secret cookie'). 
true 

net:ping('mongooseim@localhost').
pong

Check out the docs

like image 1
Maqbool Avatar answered Nov 19 '22 00:11

Maqbool