HammerSpb
HammerSpb

Reputation: 735

Erlang: How do I allow more than 1024 connection with Mochiweb?

I tried to increase file descriptors max limit on GNU/Linux:

$ ulimit -n 999999

and I'm starting the server with -env ERL_MAX_PORTS 4096.

Whenever I'm using test util, after 1012-1024 opened connection I'm getting the messages "Closed: socket_closed_remotely" and "Closed: emfile".

Upvotes: 2

Views: 2045

Answers (2)

HammerSpb
HammerSpb

Reputation: 735

I found my mistake. I called ulimit for another shell.

Upvotes: 3

Yasir Arsanukayev
Yasir Arsanukayev

Reputation: 9676

Try tweaking max option which is passed to mochiweb_socket_server:start/1 from your APPLICATION_web:start/1, where APPLICATION is the name of your application; for example your application called helloworld, then you will find the function start/1 in file ./src/helloworld_web.erl which looks like:

start(Options) ->
    {DocRoot, Options1} = get_option(docroot, Options),
    Loop = fun (Req) ->
              ?MODULE:loop(Req, DocRoot)
    end,
    mochiweb_http:start([{name, ?MODULE}, {loop, Loop} | Options1]).

Modify call to mochiweb_http:start/1 to include the option max:

    mochiweb_http:start([{max, 1000000}, {name, ?MODULE}, {loop, Loop} | Options1]).

Hope that helps.

Upvotes: 1

Related Questions