Re: Help! warn: error raised: Error: accept EMFILE (with socket.io)

2,843 views
Skip to first unread message

mscdex

unread,
Nov 10, 2012, 8:48:45 PM11/10/12
to nodejs
On Nov 10, 7:33 pm, Maximiliano Guzenski <maxguzen...@gmail.com>
wrote:
> I already setted "ulimit -n 200000" on linux, but it didn't fix this issue.
> I changed /etc/limits.conf as well.

You can double check the values being used by finding your app's
process id and then `cat /proc/<pid>/limits`

Maximiliano Guzenski

unread,
Nov 11, 2012, 6:11:12 AM11/11/12
to nod...@googlegroups.com
looks like that "ulimit -n 200000" does works:

cat /proc/3475/limits
Limit                     Soft Limit           Hard Limit           Units     
Max cpu time              unlimited            unlimited            seconds   
Max file size             unlimited            unlimited            bytes     
Max data size             unlimited            unlimited            bytes     
Max stack size            8388608              unlimited            bytes     
Max core file size        0                    unlimited            bytes     
Max resident set          unlimited            unlimited            bytes     
Max processes             13098                13098                processes 
Max open files            1024                 4096                 files     
Max locked memory         65536                65536                bytes     
Max address space         unlimited            unlimited            bytes     
Max file locks            unlimited            unlimited            locks     
Max pending signals       13098                13098                signals   
Max msgqueue size         819200               819200               bytes     
Max nice priority         0                    0                    
Max realtime priority     0                    0                    
Max realtime timeout      unlimited            unlimited            us 

what can I do?

Maximiliano Guzenski

unread,
Nov 11, 2012, 6:14:50 AM11/11/12
to nod...@googlegroups.com
I put on /etc/security/limits.conf  (and restart):

ubuntu          hard    nofile           500000
ubuntu          soft    nofile           450000

why did it not affect "cat /proc/<pid>/limits" ?

Maximiliano Guzenski

unread,
Nov 11, 2012, 6:16:37 AM11/11/12
to nod...@googlegroups.com
sorry: looks like that "ulimit -n 200000" does NOT works...

mscdex

unread,
Nov 11, 2012, 7:56:09 AM11/11/12
to nodejs
On Nov 11, 6:16 am, Maximiliano Guzenski <maxguzen...@gmail.com>
wrote:
> sorry: looks like that "ulimit -n 200000" does NOT works...

Try putting that in your upstart script right before you execute your
node script.

Maximiliano Guzenski

unread,
Nov 11, 2012, 1:25:00 PM11/11/12
to nod...@googlegroups.com
I was using "ulimit" into upstart script... that isn't work... becouse it is just "limit", now is working!

description "xmpp node.js server"
author      "Maximiliano Guzenski"

# used to be: start on startup
# until we found some mounts weren't ready yet while booting:
start on started mountall
stop on shutdown

# Automatically Respawn:
respawn
respawn limit 10 5

#env NODE_ENV=production

limit nofile 200000 400000

script
    # Not sure why $HOME is needed, but we found that it is:
    export HOME="/home/ubuntu"
    exec sudo -u ubuntu NODE_ENV=production /usr/local/bin/node /home/ubuntu/awesome-im/server.js >> /var/log/nodejs/awesome.log 2>&1
end script

post-start script
   # Optionally put a script here that will notifiy you node has (re)started
   # /root/bin/hoptoad.sh "node.js has started!"
end script

Javier Cobos

unread,
May 13, 2013, 2:22:07 AM5/13/13
to nod...@googlegroups.com
This error is fixed here:

http://stackoverflow.com/questions/16476783/node-js-ssl-server-frozen-high-cpu-not-crashed-but-no-connections

It's related with the limit of files a process is able to open in linux. I wrote it my self so if you need any help please tell me.


On Sunday, 11 November 2012 01:33:28 UTC+1, Maximiliano Guzenski wrote:

Hi,
I have a webchat, running with socket.io (no redis) and express into a EC2 m1.small.
When I have 420 online users, nodejs/socket.io go in an error looping... in log I can see:

warn: error raised: Error: accept EMFILE
warn: error raised: Error: accept EMFILE
warn: error raised: Error: accept EMFILE
warn: error raised: Error: accept EMFILE
... many times ...

ubuntu upstart doesn't detect this error, and my app be in an error loop forever.

I already setted "ulimit -n 200000" on linux, but it didn't fix this issue. I changed /etc/limits.conf as well.

I use nodejs 0.8.14 and last version of socket.io

My app use less then 30% of memory and 10% of CPU.

Please, anyone can helpe me?

Robert j

unread,
Aug 22, 2013, 8:02:20 AM8/22/13
to nod...@googlegroups.com
Does anyone solved it in different way than change ulimit? Like The Yak wrote- it only allows files to accumulate longer so it is not solution.

Reply all
Reply to author
Forward
0 new messages