tcp -> rabbitmq gives emfile + 541
Hi all and thank you for the Erlang Factory talks
I have tried to implement a very basic erlang tcp server which accepts requests and forwards everything to rabbitmq exchanges. This is meant to be a workaround the lack of a 0.8 C client, I am trying to get Postgresql to send notifications through rabbitmq. Things work as expected up to a point, until I get
{{badmatch,{error,emfile}},[{cinumber_daemon,connect,1}]}
followed by
Broker forced connection: 541 -> <<"INTERNAL_ERROR">>
I am pretty much an Erlang newbie, so please forgive me if this is not really a rabbitmq issue. This could be useful to others, too.
cheers, Michael
Here is the relevant part of the code (I am certain recv_loop terminates):
recv_loop also does all the rabbity stuff (closes channel, closes connection)
--------------------------------------------------------------------------------------------------
start_server() ->
% start up the service and error out if we cannot
case gen_tcp:listen(?LISTEN_PORT, ?TCP_OPTS) of
{ok, Listen} ->
spawn(?MODULE, connect, [Listen]),
io:format("~p Server Started.~n", [erlang:localtime()]),
sleep(infinity);
Error ->
io:format("Error: ~p~n", [Error])
end.
connect(Listen) ->
{ok, Socket} = gen_tcp:accept(Listen),
inet:setopts(Socket, ?TCP_OPTS),
% kick off another process to handle connections concurrently
spawn(fun() -> connect(Listen) end),
recv_loop(Socket),
gen_tcp:close(Socket),
exit(normal).
_______________________________________________
rabbitmq-discuss mailing list
rabbitmq-discuss@...
http://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss