Too many open files on socket

1

I have a big problem and that is that my company's production application which I unfortunately can't shutdown and restart ( I am unsure how, and I don't want to do any mistake) is spitting out a lot of exceptions on too many files open when trying to open a socket to read from an ftp server.

2013-01-02 16:19:03,222 ERROR [main] software.background.Program(Program.java:doExecute{225}) - Exception during ftp transfer
someclasses.ftp.FtpException: Could not create connection to xxxx
    at someclasses.communication.ftp.FtpImpl.connect(FtpImpl.java:114)
    at Program.doExecute(Program.java:176)
    at Program.main(Program.java:287)
Caused by: java.net.SocketException: Too many open files
    at java.net.Socket.createImpl(Socket.java:397)
    at java.net.Socket.<init>(Socket.java:371)
    at java.net.Socket.<init>(Socket.java:189)
    at someclasses.Ftp.connect(Ftp.java:386)

I understand that the per application limit of open files / sockets and so on is reached. Is there any way to increase this maximum for the time being without closing the application? I have run the command ulimit and it states unlimited. I've tried to check how many connections it has open with the lsof -p PID command but it states "command not found".

Would be very glad if someone could help me find another similar effect that lsof has (I think it's a red hat machine) and advice for how to fix this temporary? The most pleasant solution to this would be to increase the files / sockets the application could open. This is just a plain java application.

Thanks in advance!

EDIT another solution would be if there were any command where I could look up how this program was run from the beginning with all the eventual flags. Then I maybe could restart it with success. This is a legacy app.

Ms01

Posted 2013-01-02T15:40:05.833

Reputation: 91

to look up the full command lines for running apps use "ps -FA" – Steve Perkson – 2013-01-02T15:55:38.350

Thanks for the comment, I will probably use this if changing the ulimit -n to 2048 instead of 1024 won't fix it. http://lj4newbies.blogspot.se/2007/04/too-many-open-files.html changed it to the nofile configuration displayed in the link. You think it'll work?

– None – 2013-01-02T16:03:28.807

1Running out of file descriptor also could be hint that your app is leaking file descriptors: missing to close them if not used anymore. If this is the case, increasing the number of available file descriptors won't help in the long. – alk – 2013-01-02T16:11:19.693

can you check /proc/sys/fs/file-max – None – 2013-01-02T16:27:15.963

@JoG That is a system maximum. – Peter Lawrey – 2013-01-02T16:29:45.183

@alk yes, probably. I am however not looking for something in the long run. I can't however fix this bug and release now so I am looking for a temporary solution. – None – 2013-01-02T16:55:40.087

I did not try this: It might be possible to attach to the process in question using a debugger, identify stale file descriptors and close them via the debuggers command line by issuing a close(fdStale) on each of them. – alk – 2013-01-02T17:01:57.230

Answers

1

It all ended with a restart of the application. I changed the ulimit -n to 2048 and reloaded the config. However, all processes inherited the old config and the application had to be restarted.

Ms01

Posted 2013-01-02T15:40:05.833

Reputation: 91