node.js - Tcp server not accepting connection after certain time -
i implementing tcp server in nodejs accepts connections gps devices , code being monitored forever. code not crashing after time server not accepting new connections. once restart server works fine again. don't have clue whats wrong. os ubuntu 14.04. appreciated.
edit:
time after server not accepting connections around 6 days.
net.createserver(function(sock){ sock.on('data',function(data){ //converting data ascii. //parsing data,doing calculation //fetching user_id redis.(i device id gps device, there user_id associated device ids). //posting api using rest-client }); });
edit 2: there size of virtual memory. virtual memory size around 940mb. ?
i've worked depeloping same type of system, question have nostalgia me. problem file descriptor:
in unix , related computer operating systems, file descriptor (fd, less fildes) abstract indicator (handle) used access file or other input/output resource, such pipe or network connection.
then, need increase file descriptor limit in linux server follow:
edit kernel parameter file /etc/sysctl.conf. add line fs.file-max=[new value] it.
vim /etc/sysctl.conf fs.file-max = 500000
apply changes:
sysctl -p
to change ulimit setting, edit file /etc/security/limits.conf , set hard , soft limits.
vi /etc/security/limits.conf * soft nofile 90000 * hard nofile 90000
apply changes:
reboot
now test new system settings using following commands:
#ulimit -a open files (-n) 90000
check current open file descriptor limit:
# more /proc/sys/fs/file-max 500000
tip1: find out how many file descriptors being used
# more /proc/sys/fs/file-nr
tip2: add conjob restart socket server (node.js app) each week. hope helps.
Comments
Post a Comment