When I try to run on my server machine command
./rabbitmq-server
I the get following:
WARNING: Removing trailing slash from RABBITMQ_LOG_BASE
Removing trailing slash from RABBITMQ_MNESIA_BASE
Protocol 'inet_tcp': register/listen error: econnrefused
Backstory:
This is my first time I’m trying to install RabbitMQ-Server just using ssh.
Step-by-step what I did so far would be:
- wget https://www.rabbitmq.com/releases/rabbitmq-server/v3.6.0/rabbitmq-server-3.6.15.zip
- unzip rabbitmq-server-3.6.15.zip
- nano Makefile # change prefix to rabbitMQ in home directory PREFIX ?= /home/user/rabbitmq
- gmake
- gmake install
- cd ~/rabbitmq/lib/erlang/lib/rabbitmq_server-3.6.15/sbin/
- export RABBITMQ_MNESIA_BASE=/home/user/rabbitmq/lib/erlang/lib/rabbitmq_server-3.6.15/sbin/
export RABBITMQ_LOG_BASE=/home/user/rabbitmq/ - ./rabbitmq-server
And here comes the error. I was told that maybe «unlocking» ports would do the trick, but
- I don’t know how to do that
- I don’t know if that’s the case
asked Jul 31, 2018 at 15:08
3
The error Protocol 'inet_tcp': register/listen error: econnrefused
means that the Erlang node tried to connect to epmd (the Erlang port mapper daemon) to register its name, but failed to connect.
That shouldn’t happen: epmd should be started when the Erlang node starts up. You could try running epmd
manually in the shell, and see if it reports any errors.
If it says failed to bind socket: Operation not permitted
, check if something else is using port 4369 (which is the port that epmd tries to listen on).
answered Aug 1, 2018 at 8:47
legoscialegoscia
39.3k22 gold badges115 silver badges163 bronze badges
4
3 HTTP Client
3.1
Configuration
The HTTP client default profile is started when the Inets
application is started and is then available to all processes on
that Erlang node. Other profiles can also be started at
application startup, or profiles can be started and stopped
dynamically in runtime. Each client profile spawns a new
process to handle each request, unless a persistent connection
can be used with or without pipelining.
The client adds a host header and an empty
te header if there are no such headers present in the request.
The client supports IPv6 as long as the underlying mechanisms also do
so.
The following is to be put in the Erlang node application configuration file
to start a profile at application startup:
[{inets, [{services, [{httpc, PropertyList}]}]}]
For valid properties, see
httpc(3).
3.2
Getting Started
Start Inets:
The following calls use the default client profile.
Use the proxy «www-proxy.mycompany.com:8000»,
except from requests to localhost. This applies to all the
following requests.
Example:
2 > httpc:set_options([{proxy, {{"www-proxy.mycompany.com", 8000}, ["localhost"]}}]). ok
The following is an ordinary synchronous request:
3 > {ok, {{Version, 200, ReasonPhrase}, Headers, Body}} = httpc:request(get, {"http://www.erlang.org", []}, [], []).
With all the default values presented, a get request can also be written
as follows:
4 > {ok, {{Version, 200, ReasonPhrase}, Headers, Body}} = httpc:request("http://www.erlang.org").
The following is a https request and with verification of the host:
5 > {ok, {{Version, 200, ReasonPhrase}, Headers, Body}} = httpc:request(get, {"https://www.erlang.org", []}, [{ssl, httpc:ssl_verify_host_options(true)}], []).
The following is an ordinary asynchronous request:
6 > {ok, RequestId} = httpc:request(get, {"http://www.erlang.org", []}, [], [{sync, false}]).
The result is sent to the calling process as
{http, {ReqestId, Result}}.
In this case, the calling process is the shell, so the following
result is received:
7 > receive {http, {RequestId, Result}} -> ok after 500 -> error end. ok
This sends a request with a specified connection header:
8 > {ok, {{NewVersion, 200, NewReasonPhrase}, NewHeaders, NewBody}} = httpc:request(get, {"http://www.erlang.org", [{"connection", "close"}]}, [], []).
This sends an HTTP request over a unix domain socket (experimental):
9 > httpc:set_options([{ipfamily, local}, {unix_socket,"/tmp/unix_socket/consul_http.sock"}]). 10 > {ok, {{NewVersion, 200, NewReasonPhrase}, NewHeaders, NewBody}} = httpc:request(put, {"http:///v1/kv/foo", [], [], "hello"}, [], []).
Start an HTTP client profile:
10 > {ok, Pid} = inets:start(httpc, [{profile, foo}]). {ok, <0.45.0>}
The new profile has no proxy settings, so the connection is refused:
11 > httpc:request("http://www.erlang.org", foo). {error, econnrefused}
Stop the HTTP client profile:
12 > inets:stop(httpc, foo). ok
Alternative way to stop the HTTP client profile:
13 > inets:stop(httpc, Pid). ok
When I try to run on my server machine command
./rabbitmq-server
I the get following:
WARNING: Removing trailing slash from RABBITMQ_LOG_BASE
Removing trailing slash from RABBITMQ_MNESIA_BASE
Protocol 'inet_tcp': register/listen error: econnrefused
Backstory:
This is my first time I’m trying to install RabbitMQ-Server just using ssh.
Step-by-step what I did so far would be:
- wget https://www.rabbitmq.com/releases/rabbitmq-server/v3.6.0/rabbitmq-server-3.6.15.zip
- unzip rabbitmq-server-3.6.15.zip
- nano Makefile # change prefix to rabbitMQ in home directory PREFIX ?= /home/user/rabbitmq
- gmake
- gmake install
- cd ~/rabbitmq/lib/erlang/lib/rabbitmq_server-3.6.15/sbin/
- export RABBITMQ_MNESIA_BASE=/home/user/rabbitmq/lib/erlang/lib/rabbitmq_server-3.6.15/sbin/
export RABBITMQ_LOG_BASE=/home/user/rabbitmq/ - ./rabbitmq-server
And here comes the error. I was told that maybe «unlocking» ports would do the trick, but
- I don’t know how to do that
- I don’t know if that’s the case
asked Jul 31, 2018 at 15:08
3
The error Protocol 'inet_tcp': register/listen error: econnrefused
means that the Erlang node tried to connect to epmd (the Erlang port mapper daemon) to register its name, but failed to connect.
That shouldn’t happen: epmd should be started when the Erlang node starts up. You could try running epmd
manually in the shell, and see if it reports any errors.
If it says failed to bind socket: Operation not permitted
, check if something else is using port 4369 (which is the port that epmd tries to listen on).
answered Aug 1, 2018 at 8:47
legoscialegoscia
39.3k22 gold badges115 silver badges163 bronze badges
4
Connecting the Erlang client with the Python server gives connection error:
Erlang client:
– the examples are taken from the Apache Thrift tutorials —
-module(client).
-include(«calculator_thrift.hrl»).
-export([t/0]).
p(X) ->
io:format(«~p~n», [X]),
ok.t() ->
Port = 9090,Unknown macro: {ok, Client0}
= thrift_client_util:new(«localhost»,
Port,
calculator_thrift,
[]),{Client1, {ok, ok}} = thrift_client:call(Client0, ping, []),
io:format(«ping~n», []),{Client2, {ok, Sum}} = thrift_client:call(Client1, add, [1, 1]),
io:format(«1+1=~p~n», [Sum]),{Client3, {ok, Sum1}} = thrift_client:call(Client2, add, [1, 4]),
io:format(«1+4=~p~n», [Sum1]),Work = #’Work’
Unknown macro: {op=?TUTORIAL_OPERATION_SUBTRACT, num1=15, num2=10}
,
{Client4, {ok, Diff}} = thrift_client:call(Client3, calculate, [1, Work]),
io:format(«15-10=~p~n», [Diff]),{Client5, {ok, Log}} = thrift_client:call(Client4, getStruct, [1]),
io:format(«Log: ~p~n», [Log]),Client6 =
try
Work1 = #’Work’Unknown macro: {op=?TUTORIAL_OPERATION_DIVIDE, num1=1, num2=0}
,
{ClientS1, {ok, _Quot}} = thrift_client:call(Client5, calculate, [2, Work1]),io:format(«LAME: exception handling is broken~n», []),
ClientS1
catch
throw:Unknown macro: {ClientS2, Z}
->
io:format(«Got exception where expecting — the » ++
«following is NOT a problem!!!~n»),
p(Z),
ClientS2
end,{Client7, {ok, ok}} = thrift_client:call(Client6, zip, []),
io:format(«zip~n», []),{_Client8, ok} = thrift_client:close(Client7),
ok.
Python server:
#!/usr/bin/env python
from tutorial import Calculator
from tutorial.ttypes import InvalidOperation, Operationfrom shared.ttypes import SharedStruct
from thrift.transport import TSocket
from thrift.transport import TTransport
from thrift.protocol import TBinaryProtocol
from thrift.server import TServerclass CalculatorHandler:
def _init_(self):
self.log = {}def ping(self):
print(‘ping()’)def add(self, n1, n2):
print(‘add(%d,%d)’ % (n1, n2))
return n1 + n2def calculate(self, logid, work):
print(‘calculate(%d, %r)’ % (logid, work))if work.op == Operation.ADD:
val = work.num1 + work.num2
elif work.op == Operation.SUBTRACT:
val = work.num1 — work.num2
elif work.op == Operation.MULTIPLY:
val = work.num1 * work.num2
elif work.op == Operation.DIVIDE:
if work.num2 == 0:
x = InvalidOperation()
x.whatOp = work.op
x.why = ‘Cannot divide by 0’
raise x
val = work.num1 / work.num2
else:
x = InvalidOperation()
x.whatOp = work.op
x.why = ‘Invalid operation’
raise xlog = SharedStruct()
log.key = logid
log.value = ‘%d’ % (val)
self.log[logid] = logreturn val
def getStruct(self, key):
print(‘getStruct(%d)’ % (key))
return self.log[key]def zip(self):
print(‘zip()’)if _name_ == ‘_main_’:
handler = CalculatorHandler()
processor = Calculator.Processor(handler)
transport = TSocket.TServerSocket(port=9090)
tfactory = TTransport.TBufferedTransportFactory()
pfactory = TBinaryProtocol.TBinaryProtocolFactory()server = TServer.TSimpleServer(processor, transport, tfactory, pfactory)
- You could do one of these for a multithreaded server
- server = TServer.TThreadedServer(
- processor, transport, tfactory, pfactory)
- server = TServer.TThreadPoolServer(
- processor, transport, tfactory, pfactory)
print(‘Starting the server…’)
server.serve()
print(‘done.’)
Runtime protocol:
EBIN Path : D:SoftDevelopmentProjectserlang-and-thrift_ideaerlang-and-thrift_builddefaultliberlang_and_thriftebin D:SoftDevelopmentProjectserlang-and-thrift_ideaerlang-and-thrift_builddefaultlibjsxebin D:SoftDevelopmentProjectserlang-and-thrift_ideaerlang-and-thrift_builddefaultlibthriftebin
——————————————
Eshell V9.0 (abort with ^G)
1> client:t().
- exception error: no match of right hand side value
Unknown macro: {error,econnrefused}
in function client:t/0 (d:/SoftDevelopment/Projects/erlang-and-thrift_idea/erlang-and-thrift/_build/default/lib/erlang_and_thrift/src/client.erl, line 33)
2> Terminate batch job (Y/N)? yD:SoftDevelopmentProjectserlang-and-thrift_ideaerlang-and-thrift>tcping64 localhost 9090
Probing ::1:9090/tcp — Port is open — time=0.580ms
Probing ::1:9090/tcp — Port is open — time=0.622ms
Probing ::1:9090/tcp — Port is open — time=1.038ms
Probing ::1:9090/tcp — Port is open — time=1.050msPing statistics for ::1:9090
4 probes sent.
4 successful, 0 failed.
Approximate trip times in milli-seconds:
Minimum = 0.580ms, Maximum = 1.050ms, Average = 0.822ms