Why Node.connect failing?

Hi

I’m trying to connect two computers in different machines, the two of them under the same network.
I’ve achieved this using the same computer with two terminal sessions open, and I think I get it, but it doesn’t work when I’m using two separated machines.

My scenario is:

Computer 1:
IP: 192.168.0.1


iex> iex --name one@192.168.0.1 --cookie chocolate --erl '-kernel inet_dist_listen_min 9000' --erl '-kernel inet_dist_listen_max 9000'

Computer 2:
IP: 192.168.0.2


iex1> iex --name two@192.168.0.2 --cookie chocolate --erl '-kernel inet_dist_listen_min 9000' --erl '-kernel inet_dist_listen_max 9000'

iex2> Node.connect :'one@192.168.0.1'
false

At this point I could guess that this should work, but it doesn’t :(,

Can somebody guide me through the process of connecting two nodes in different machines under a LAN network?

Thanks in advance.

You shouldn’t run the command in iex but in a shell like bash or zsh.

Also, when I use your command as is in zsh I see this:

Erlang/OTP 20 [erts-9.3] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:10] [hipe] [kernel-poll:false]

-kernel inet_dist_listen_min 9000 : Unknown option

So I wonder how this worked locally at all.

The current command at least looks like as if it were missing a cookie.

3 Likes

Hi, Sorry I just realize I didn’t add the cookie. However, even if I add it in the command I can’t connect the two nodes

Is it the same cookie and have you checked your firewall? Is epmd running on the host you are trying to connect to? Does connect return instantly or does some time pass? Are you able to create the connection the other way around? Have you checked if the IPs are actually correct? Are you able to otherwise initiate connections between those computers (eg. SSH, ping, telnet, HTTP, RDP, VNC)?

Is it the same cookie and have you checked your firewall?

  • What should I check exactly, I can see that the firewall is turned off

Is epmd running on the host you are trying to connect to? Does connect return instantly or does some time pass?

  • If I run epmd -names both computers I have a success response:

Computer 1:


> epmd -names
epmd: up and running on port 4349 with data:
name one at port 9000

Computer 2:


> epmd -names
epmd: up and running on port 4349 with data:
name two at port 9000

With this I can see that both epmd’s are running in the same port, and both apps are running also in the same port.

Are you able to create the connection the other way around?

  • No, I tried both directions

Have you checked if the IPs are actually correct?

  • Yes, both IP’s are correct

Are you able to otherwise initiate connections between those computers (eg. SSH, ping, telnet, HTTP, RDP, VNC)?

  • I did this:

ping 192.168.0.1
PING 192.168.1.68 (192.168.0.1): 56 data bytes
64 bytes from 192.168.0.1: icmp_seq=0 ttl=64 time=105.282 ms
64 bytes from 192.168.0.1: icmp_seq=1 ttl=64 time=3.750 ms
64 bytes from 192.168.0.1: icmp_seq=2 ttl=64 time=2.611 ms
64 bytes from 192.168.0.1: icmp_seq=3 ttl=64 time=2.152 ms
64 bytes from 192.168.0.1: icmp_seq=4 ttl=64 time=7.478 ms
64 bytes from 192.168.0.1: icmp_seq=5 ttl=64 time=10.761 ms

I can guess that both computers are seeing each other, but I’m not sure.

Quick question, I’m assuming that because both computers are connected to the same Wireless network this should work, I’m I wrong? should the computers be connected by cable or something like that?

thanks

Then you usually do not need to check more. But depending on your system, are you sure you have shut down firewalls? Especially if you are on windows, there is sometimes an annoying pop up, which might enable or disable internet access for a single application.

This makes me nervous, why is ping showing 2 different IP addresses here? Do the computers perhaps have multiple IPs? Have you checked all of them?

Thats somewhere on layers 1-2, the BEAMs node connection somewhere on 6-7, so that shouldn’t matter…

Have you checked if the request actually hits the other computer using tools like wireshark/tcpdump?

This really is regular network debugging (which I tend to wait for my coworkers to do it :wink: ) and not specific to erlang or elixir.

1 Like

What are the IP’s of both computers? It’s a little off for one of them to be 192.168.0.1 because in most home setups that’s the IP of the router instead of a computer.

1 Like

Yeah, I do have the same feeling after the ping output.

2 Likes

Sorry I was trying to exemplify the IP’s, but this is the real info

Computer 1:


iex --name one@192.168.1.64 --cookie chocolate --erl '-kernel inet_dist_listen_min 9000' --erl '-kernel inet_dist_listen_max 9000'

Ping:


ping 192.168.1.68
PING 192.168.1.68 (192.168.1.68): 56 data bytes
64 bytes from 192.168.1.68: icmp_seq=0 ttl=64 time=49.161 ms
64 bytes from 192.168.1.68: icmp_seq=1 ttl=64 time=15.129 ms
64 bytes from 192.168.1.68: icmp_seq=2 ttl=64 time=188.599 ms
64 bytes from 192.168.1.68: icmp_seq=3 ttl=64 time=177.096 ms
64 bytes from 192.168.1.68: icmp_seq=4 ttl=64 time=322.621 ms
64 bytes from 192.168.1.68: icmp_seq=5 ttl=64 time=2.274 ms

Computer 2:

iex --name two@192.168.1.68 --cookie chocolate --erl '-kernel inet_dist_listen_min 9000' --erl '-kernel inet_dist_listen_max 9000'

Ping:


ping 192.168.1.64
PING 192.168.1.64 (192.168.1.64): 56 data bytes
64 bytes from 192.168.1.64: icmp_seq=0 ttl=64 time=48.375 ms
64 bytes from 192.168.1.64: icmp_seq=1 ttl=64 time=4.841 ms
64 bytes from 192.168.1.64: icmp_seq=2 ttl=64 time=2.179 ms
64 bytes from 192.168.1.64: icmp_seq=3 ttl=64 time=2.325 ms

Note:

Firewall is off for both computers, how do I know this?

thanks

Can you please check on what IP the epmd and your BEAM binds to?

On my system I’d use netstat -lnpt | grep "beam\|epmd" (or ss -lnpt | grep "beam\|epmd") to check.

Please make sure the IP that they bound to is either 0.0.0.0 or the one specified in the name when starting the iex.

Also, again, I’m asking if you have used tcpdump to check whether or not packages reach the other end of the connection.

Also please make sure, that there is no firewall on the WiFi access point interfering with your experiments.

1 Like

I’m on mac so ss is not the option here, but netstat -lnt | grep "beam\|epmd" gives me 0 results, I don’t know if that means that epmd is not running, but I think it is, since I can see this then I run epmd -names

epmd -names
epmd: up and running on port 4349 with data:
name one at port 9000

I don’t really know how to use tcpdump but I’ll search a little bit about it.

thanks

I used wireshark and looks like the packages a passing through the network in both directions, so the last thing that can be the issue is the access point but I’m not sure how to verify that.