0

I have an erlang app with API and i need to call these API functions from a nodejs server and process the response. For example: Nodejs sends data to app, app processes the data then sends it back to nodejs and finally nodejs processes the result.

So far my best idea was launching the app in a cmd as a child process but that is really hard to work with and when i looked up, all i found was people suggesting not to use nodejs but that is unfortunately not an option for me.

EDIT: For clarification my question is what is the best way to call the erlang functions from nodejs

BenJoe
  • 15
  • 3

2 Answers2

2

Not sure I understand your request completely but for running the nodejs project on a server , I highly recommend using pm2. pm2 will manage your nodejs application. See http://pm2.keymetrics.io/

I don't know how large the data is you are sending, but if the data is large enough (i.e. processing it takes longer than 200ms) you might want to look into processing it asynchronously.

Guy Hagemans
  • 496
  • 1
  • 4
  • 15
  • Sorry if my question is confusing english is my second language, the data is not so big, basically i want o call erlang from nodejs and all the data is sent in erlang tuples. My current solution is an async cmd sub process that always in the background waiting for input. – BenJoe Feb 05 '19 at 10:32
  • so is your question how to run the nodejs application or how to call the erlang API from nodejs? – Guy Hagemans Feb 05 '19 at 10:44
  • calling erlang api from nodejs – BenJoe Feb 05 '19 at 11:14
1

My suggestion is to implement Erlang application API as a RESTfull API using one of Erlang open source web servers Cowboy, Mochiweb, Webmachine. In this case you can invoke Erlang API from NodeJs using HTTP client (you can find a lot of implementation of HTTP client for Javascript and NodeJS especially). This way is easy for implementation and maintenance.

There is no easy way to invoke remotely Erlang functions from JavaScript. Erlang has ability to communicate with C/C++ (Erlang Port) and Java (JInterface) application only.

Alexei K
  • 142
  • 1
  • 5