RethinkDb EMFILE error

156 views Asked by At

Here is my project using Node.js, Socket.io, RethinkDb

https://github.com/plever7/online-visitors-counter

Everything is going fine. But if we have many connection via socket in server.js we get error such as. After 5,10 sec. the code running successfully again itself.

ReqlDriverError: Failed to connect to localhost:28015
Full error:
{
 "code": "EMFILE",
  "errno": "EMFILE",
  "syscall": "getaddrinfo"
}.
at Socket.<anonymous> (/root/node_modules/rethinkdbdash/lib/connection.js:89:12)
at Socket.g (events.js:180:16)
at Socket.emit (events.js:95:17)
at net.js:834:16
at process._tickCallback (node.js:442:13)

Above EMFILE indicates, I reached file descriptor limit of OS, but I think there is another problem. Here is information from OS :

the maximum number file handlers for entire system is:

[root@socketio ~]# cat /proc/sys/fs/file-max
185294


current usage of handles:

[root@socketio ~]# cat /proc/sys/fs/file-nr
4832 0 185294


The lsof output for 3 server.js process:

[root@socketio ~]# lsof -p 4175 | wc -l
464
[root@socketio ~]# lsof -p 30071 | wc -l
1058
[root@socketio ~]# lsof -p 30084 | wc -l
1064


[root@socketio ~]# ulimit -Hn
65535
[root@socketio ~]# ulimit -Sn
65535
0

There are 0 answers