Fl4m3Ph03n1x

Fl4m3Ph03n1x

EMPD ports prevent Obverver from running remotely

Background

I have invested the past 2 days trying to connect my localhost machine to a production machine so I can use :observer.start() and see why it is consuming so much CPU.

At this point I am so desperate I decided to scratch everything and try another approach. This time I read the entirety of this discussion:

But to no avail.

My approach

This new approach is based on this tutorial (which originated the above mentioned post)

On 1st terminal in local machine:

ssh user@remote-host "epmd -names"
    epmd: up and running on port 4369 with data:
    name my_super_duper_app at port 42267
ssh -L 4369:localhost:4369 -L 42267:localhost:42267 remote-host

On 2nd terminal in local machine:

erl -name debug@127.0.0.1 -setcookie super_duper_cookie -remsh my_super_duper_app@remote-host

Whereremote-host is the public IP of the machine I want to connect to. The rest should be self explanatory.

Problem

After executing the command:

ssh -L 4369:localhost:4369 -L 42267:localhost:42267 remote-host

I am logged into the remote machine. This is good. What is not good is the message I see at the top:

bind [127.0.0.1]:4369: Address already in use
channel_setup_fwd_listener_tcpip: cannot listen to port: 4369
Welcome to Ubuntu 16.04.4 LTS (GNU/Linux 4.15.0-1026-gcp x86_64)

Of course the port 4369 is being used. It is the port where empd is running. What does it mean it cannot bind and listen to it? which machine do I have to kill to fix this?

As a consequence (or so I believe), when I run the command of the 2nd terminal I see this:

*** ERROR: Shell process terminated! (^G to start new job) ***

I am so confused. What am I missing?

Marked As Solved

rodrigues

rodrigues

yes

This is what I run locally to connect to the remote node (the app in production, for example). USR is a local name, COOKIE is the cookie in the remote node, and APP the user in remote host.

Yes, you run it local just like the other iex command. The difference is that I use this one to run observer. The other to use the IEx.

You will see the applications in the observer menu, “Nodes”. There you should be able to switch to the remote application you wanna observe.

Does it work now? :smiley:

Also Liked

Fl4m3Ph03n1x

Fl4m3Ph03n1x

What dark magic is this?

The past 2 days of my life have been consumed by this. And you, out of nowhere, somehow managed to bring me a solution. I never thought this would work. To be honest, I quite don’t understand why, but who cares, it works !

Summary

To summarize (since I am sure I will forget about this 4 steps of hell) I am putting it here everything I did.

All steps in local machine:

  1. get the ports from the remote server:

    ssh remote-user@remote-ip "epmd -names"

    epmd: up and running on port 4369 with data:
    name super_duper_app at port 43175

2: create a ssh tunel with the ports:

ssh remote-user@remote-ip -L4369:localhost:4369 -L43175:localhost:43175

  1. On another terminal in your local machine, run a iex terminal with the cookie the app in your remote server is using. Then connect to it and start observer:

    iex --name observer@127.0.0.1 --cookie super_duper_cookie

    Node.connect :"super_duper_app@127.0.0.1"
    true
    :observer.start

With observer started, select the machine from the Nodes menu.

rodrigues

rodrigues

I have this module that generate the instructions to connect that I’ve posted here, so you don’t need to get the epmd port every time. You need to replace some module variables, and beware @app is the same as remote user for us, not sure if it’s just gonna work for you.

Cheers

axelson

axelson

Scenic Core Team

Something like

sudo lsof -t -i:4369

Should show you the process that has bound port 4369 locally. So you can run sudo lsof -t -i:4369 | xargs kill

If lsof isn’t working for you you could also try something like netstat -anl |grep 4369

axelson

axelson

Scenic Core Team

Aren’t step 1 and 2 the same as in your original post? It sounds like the major issue you fixed is whatever was originally causing you this error after step 2:

bind [127.0.0.1]:4369: Address already in use
channel_setup_fwd_listener_tcpip: cannot listen to port: 4369
Fl4m3Ph03n1x

Fl4m3Ph03n1x

Following your suggestions to kill processes using the port also help immensely, that is true.

Thanks for the script and for the help. We will change some parts of the script but the overall idea is clear!

Where Next?

Popular in Questions Top

bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New
aalberti333
As the title describes, I’m trying to run Enum.map() over a list of key/value pairs, where the value is a map. My data looks like this: ...
New
vertexbuffer
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
stefanchrobot
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
alice
Hey, Just curious what are the main benefits of Elixir compared to Clojure? When is Elixir more useful than Clojure and vice versa? Th...
New
gonzofish
I’m currently trying to understand how to join three tables using Ecto. All the examples I’ve seen use 2, so maybe I’m just missing somet...
New
LegitStack
I’m trying to make a websocket server in Phoenix or raw Elixir. I heard about gun, I think I could use cowboy, but since I’m not that sma...
New
chewm
Hi guys, nice to meet you to the whole forum, I’m new here, I’m trying to configure visual studio code for elixir, right now the intellis...
New
skosch
To my knowledge, put_in, Map.update etc. all have the one limitation of not automatically creating intermediate keys when needed (for exa...
New
jc00ke
Expanding on this topic: https://forum.elixirforum.net/t/map-typespec-question/19217 Let’s say I have a map with required and optional k...
New

Other popular topics Top

William
I would like to know that is there any online source for learning Phoenix Framework for building E-Commerce Store? Any advantage on build...
New
lessless
I believe there are people here who are dealing with CSV files import on the daily basis, and since Excel is a really popular tool there ...
New
gshaw
What is the idiomatic way of matching for not nil in Elixir? E.g., First way: defp halt_if_not_signed_in(conn, signed_in_account) when...
New
openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
Harrisonl
We have an ECS cluster with 4 services, where each task joins a single cluster, via discovery ECS discovery service. Currently when I de...
New
Jim
As a follow up to my earlier question: I have the code compiling and running but not getting a successful login from the rest server. ...
New
freewebwithme
Using vs code and installed ElixirLS: support and debugger. And I got an error popped up on start up says Failed to run ‘elixir’ comma...
New
rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list....
New
alice
Hey, Just curious what are the main benefits of Elixir compared to Clojure? When is Elixir more useful than Clojure and vice versa? Th...
New
qwerescape
Is there a way to get the call stack or stack trace at any point in the code? Not from exceptions, but an expression that returns how the...
New

We're in Beta

About us Mission Statement