Hi all and thank you for the Erlang Factory talks<br><br>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 <br>
<br>{{badmatch,{error,emfile}},[{cinumber_daemon,connect,1}]}<br><br>followed by<br><br>Broker forced connection: 541 -> <<"INTERNAL_ERROR">><br><br>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.<br>
<br>cheers, Michael<br><br>Here is the relevant part of the code (I am certain recv_loop terminates):<br>recv_loop also does all the rabbity stuff (closes channel, closes connection)<br><br>--------------------------------------------------------------------------------------------------<br>
<br><div style="margin-left: 40px;">start_server() -><br> % start up the service and error out if we cannot<br> case gen_tcp:listen(?LISTEN_PORT, ?TCP_OPTS) of<br> {ok, Listen} -><br> spawn(?MODULE, connect, [Listen]),<br>
io:format("~p Server Started.~n", [erlang:localtime()]),<br>
sleep(infinity);<br> Error -><br> io:format("Error: ~p~n", [Error])<br> end.<br><br>connect(Listen) -><br> {ok, Socket} = gen_tcp:accept(Listen),<br> inet:setopts(Socket, ?TCP_OPTS),<br>
% kick off another process to handle connections concurrently<br> spawn(fun() -> connect(Listen) end),<br> recv_loop(Socket),<br> gen_tcp:close(Socket),<br> exit(normal).<br></div><br>