开发者

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

开发者 https://www.devze.com 2023-02-06 21:49 出处:网络
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.

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".


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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消