| Author |
Message |
< Erlang ~ newbie distributed erlang. |
| wallink |
Posted: Sat Dec 01, 2007 9:15 am |
|
|
|
Joined: 01 Dec 2007
Posts: 5
Location: Göteborg
|
Hello everybody and MERRY CHRISTMAS!
I'm very new to erlang and have started to teach myself. I have started with one of the tutorials on erlang.org.
In the concurrency section there is an messenger example where you have a server that keeps track of all the clients and forwards messages from client to client.
The whole thing is built around the message-passing between erlang nodes.
My problem is, that I can get it to work with one computer with many erlang-shells open (but only in "local mode" <- will try to explain) but not when using "global mode" <- will try to explain or over the internet. I don't have my computers connected in LAN at the moment so can't test that.
"local mode": starting erlang with: erl -sname name
"global mode": starting erlang with: erl -name name
On one computer and local mode: I get 3 terminals open one for server( (messenger@wallink)1> ) and two users
(pelle@wallink) and (kalle@wallink)....And using messages-passing and connection to server with messenger@wallink goes perfectly.
but when I changes and starts all 3 shells with
erl -name name I get (messenger@wallink.bredbandsbolaget.se)1> in the promt where bredbandsbolaget.se is my internetprovider. And when I change the program so that the client tries to talk to messenger@wallink.bredbandsbolaget.se instead of messenger@wallink, but now it doesn't work??? why is that?
The same problem happens when I use 2 computers that will comunicat over the internet. In the tutorial I read something about you need to type the whole ip address to get it to work in "global mode" and over the internet...but I don't know how or where to write the ip address...this doesn't wotk:
messenger@111.222.111.222
Anybody knows how to get node-communication to work with "global mode" and over the internet???
THANKS!!!! |
|
|
| Back to top |
|
| francesco |
Posted: Sun Dec 02, 2007 9:10 am |
|
|
|
User
Joined: 07 Jul 2006
Posts: 249
Location: London
|
There should be no major differences if you run short (-sname) and long names (-name) on the same machine under the same user. With long names, this assumes that an /etc/hosts file exists or that the DNS server is configured.
When you start communicating across several users (and possible machines), you need to ensure that the nodes share the same cookies. The erlang nodes need to be set when when starting the Erlang nodes. Use -setcookie fooBar (Or any cookie of your choice). When you call net_adm:ping(Node), you should get back a pong, and the BIF nodes() will show they are connected.
Look at the documentation for the erlang module, and search on all BIFs which deal with cookies.
Francesco
--
http://www.erlang-consulting.com |
|
|
| Back to top |
|
| wallink |
Posted: Fri Dec 07, 2007 4:24 pm |
|
|
|
Joined: 01 Dec 2007
Posts: 5
Location: Göteborg
|
But what about when you want to use an ip address??
how do you write that? |
|
|
| Back to top |
|
| francesco |
Posted: Tue Dec 11, 2007 10:46 am |
|
|
|
User
Joined: 07 Jul 2006
Posts: 249
Location: London
|
|
| Back to top |
|
| wallink |
Posted: Thu Dec 13, 2007 9:46 pm |
|
|
|
Joined: 01 Dec 2007
Posts: 5
Location: Göteborg
|
When I use messenger@wallink to send message it workes... but when I use 'messenger@123.123.123.123' where 123.123.123.123 is my ip address I get this error:
=ERROR REPORT==== 13-Dec-2007::22:43:32 ===
** System NOT running to use fully qualified hostnames **
** Hostname 123.123.123.123 is illegal **
so the form 'joe@123.123.123.123' doesn't work or am I doing it wrong???
thanks |
|
|
| Back to top |
|
| francesco |
Posted: Mon Dec 17, 2007 6:44 pm |
|
|
|
User
Joined: 07 Jul 2006
Posts: 249
Location: London
|
You are starting your node with short names (-sname). If dealing with IP addresses, start your node with long names (-name). Remember that nodes with long names can not communicate with nodes started with short names.
Hope the above helps.
Francesco
--
http://www.erlang-consulting.com |
|
|
| Back to top |
|
|
|