File descriptor leak in socket programming

We have a complex socket programming client package in java using java.nio (Selectors, Selectable channel).
We use the package to connect to a server.
Whenever the server is down, it tries to reconnect to the server again at regular intervals.
In that case, the number of open file descriptors build up with each try. I am able to cofirm this using "pfile <pid>" command.
But, it looks like we are closing the channels, selectors and the sockets properly when it fails to connect to the server.
So we are unable to find the coding that causes the issue.
We run this program in solaris.
Is there a tool to track down the code that leaks the file descriptor.
Thanks.

Don't close the selector. There is a selector leak. Just close the socket channel. As this is a client you should then also call selector.selctNow() to have the close take final effect. Otherwise there is also a socket leak.

Similar Messages

  • Help tracking down a file descriptor leak under java 6

    I have a large application I work on that runs fine under java5 (apart from possibly the latest update) but running under java 6 results in file descriptors used for TCP sockets being leaked.
    I'm testing this under FreeBSD 6 (both i386 and amd64) using diablo JDK and a port build jdk-1.6.0.3p3 but I have had reports from other users of exactly the same issue under various linux distributions. There are some reports that going back as far as 1.6.0b5 will resolve the issue but no later version works and a few reports that the latest 1.5 updates have the same issue.
    This application is using standard IO so Socket/ServerSocket and occasionally SSLSocket, no NIO is involved. Under the problem JDKs it will run for a while before available FDs are exhausted and then fall over with a "too many open files" exception. So far I have been unable to recreate the situation in a simple testcase and the fact it works fine under earlier JDKs is really causing me issues with deciding where to look for the issue.
    Using lsof to watch the FDs that are leaked I see a steadily increasing number shown in the following state:
    java 23438 djb 54u IPv4 0xffffff0091ad02f8 0t0 TCP *:* (CLOSED)
    java 23438 djb 55u IPv4 0xffffff0105aa45f0 0t0 TCP *:* (CLOSED)
    java 23438 djb 56u IPv4 0xffffff01260c15f0 0t0 TCP *:* (CLOSED)
    java 23438 djb 57u IPv4 0xffffff012a2ae8e8 0t0 TCP *:* (CLOSED)
    If these were showing as say (CLOSE_WAIT) then I would understand where they are coming from but as far as I understand the above means the socket has been fully closed but the FD simply hasn't been released. I'm not an expert on the TCP protocol however so I may be wrong here.
    I did try making the application set SoLinger(0,true) on all sockets which of course made all connecting clients think the connection was aborted rather than gracefully closed but even with this setting the FD leak persisted.
    I've gone as far as looking at what I think are the relevant parts of the src for both JDK versions I am using but there are very few changes and nothing that obviously looks linked.
    I'm fully prepared to spend a lot of time looking into this and I'm sure I'd eventually find the cause but if anyone here already knows what the answer may be or can simply give me a nudge in the best direction to look I would be very grateful.

    After weeks of dancing around the issue for weeks, we narrowed it down to garbage collection. If we put System.gc() to run periodically , file descriptors get garbage collected properly . I've tried playing with the settings by using XX:+UseConcMarkSweepGC which seems to help a great deal while system is under stress. However when there is light activity.. the file descriptors grow again and eventually bring everything down.
    Any clues ? is there any way to make gc to perform full collection more often ?
    pls whelp !!!

  • Extracting the native file descriptor of a Socket .. HOW?

    Hello all,
    I'm trying to use JNI to make the unix system call getsockopt(), but I don't know how can I get the C socket file descriptor from a Java Socket object. I have to pass this file descriptor, an integer, to the getsockopt() function.
    Any suggestions?
    Fernando

    use reflect for assessing the priv var impl and after that , the priv member fd of the class SocketImpl.

  • Where is the file descriptor leak in this code?

    The following "appendStringToFile" method is used to append a String to a file. My java app calls this method a few times per minute, and then crashes after running for about 12 hours. The exception is "Too many open files". The code that calls it does so from a synchronized block, so concurrency is not the problem, and it would seem that only one file descriptor should be used at a time.
    Can anyone find the problem?
         public static void createParentDirectoryIfNeeded(String path) {
              String dirPath = path.substring(0, path.lastIndexOf('/'));
              File dir = new File(dirPath);
              if (!dir.exists()) {
                   dir.mkdirs();
         public static void appendStringToFile(String s, String path) {
              FileWriter fileWriter = null;
              try {
                   createParentDirectoryIfNeeded(path);
                   // create file if it doesn't already exist
                   File file = new File(path);
                   file.createNewFile();
                   if (s != null) {
                        fileWriter = new FileWriter(file, true);
                        fileWriter.write(s.toCharArray());
              } catch (IOException ioe) {
                   ErrorHandler.handleError(ioe, LOG);
              } finally {
                   if (fileWriter != null) {
                        try {
                             fileWriter.close();
                        } catch (IOException ioe) {
                             ErrorHandler.handleError(ioe, LOG);
         }Edited by: mikewertheim on Sep 26, 2008 11:54 AM
    Edited by: mikewertheim on Sep 26, 2008 11:54 AM
    Edited by: mikewertheim on Sep 26, 2008 11:55 AM
    Edited by: mikewertheim on Sep 26, 2008 11:56 AM

    I don't know what is causing your problem but I can suggest several improvements.
    1) Given a file 'f' then one can create the parent directory using   f.getParentFile().mkdirs();so that one does not need to useString dirPath = path.substring(0, path.lastIndexOf('/'));          2) There is not need to test if the directory exists before creating it. If it exists then   f.getParentFile().mkdirs(); will just do nothing.
    3) There is no need to usefile.createNewFile();because if the file does not exist then fileWriter = new FileWriter(file, true);will create it.

  • Sudden increase in open file descriptors

    Our system is live since an year and half and for the first time I encountered the following exception
    "java.net.SocketException: Too many open files"
    When our internet application stopped responding I immediately checked the number of open file descriptors on my Solaris machine by using the "lsof" command and found that it was an abnormal 600 value and as I continued monitoring it reached 1024 in matter of minutes and WebLogic gave the above exception. The current setting for file descriptors is 1024. But all these days the average number of open file descriptors was well below 220.
    I also took thread dumps and found that most of the threads were stuck at the following location
    ""ExecuteThread: '3' for queue: 'weblogic.kernel.Default'" daemon prio=5 tid=0x00883a90 nid=0x10 runnable [6d080000..6d0819c0]
         at java.net.SocketInputStream.socketRead0(Native Method)
         at java.net.SocketInputStream.read(SocketInputStream.java:129)
         at com.sybase.jdbc2.timedio.RawDbio.reallyRead(RawDbio.java:202)
         at com.sybase.jdbc2.timedio.Dbio.doRead(Dbio.java:243)
         at com.sybase.jdbc2.timedio.InStreamMgr.readIfOwner(InStreamMgr.java:512)
         at com.sybase.jdbc2.timedio.InStreamMgr.doRead(InStreamMgr.java:273)
         at com.sybase.jdbc2.tds.TdsProtocolContext.getChunk(TdsProtocolContext.java:561)
         at com.sybase.jdbc2.tds.PduInputFormatter.readPacket(PduInputFormatter.java:229)
         at com.sybase.jdbc2.tds.PduInputFormatter.read(PduInputFormatter.java:62)
         at com.sybase.jdbc2.tds.TdsInputStream.read(TdsInputStream.java:81)
         at com.sybase.jdbc2.tds.TdsInputStream.readUnsignedByte(TdsInputStream.java:114)
         at com.sybase.jdbc2.tds.Tds.nextResult(Tds.java:1850)
         at com.sybase.jdbc2.jdbc.ResultGetter.nextResult(ResultGetter.java:69)"
    There is no file descriptor leak in the application. My question is since all the threads are hung at JDBC and socket level, does it mean that a faulty query would have triggered this problem(may be the database was too busy executing a faulty query).
    I suspect this because I recieved a database exception soon after the problem appeared. One of my database insert transaction had timed out after 300 seconds. Also this was the first time I recieved this kind of an exception
    java.sql.SQLException: The transaction is no longer active - status: 'Marked rollback. [Reason=weblogic.transaction.internal.TimedOutException: Transaction timed out after 299 seconds
    Xid=BEA1-11FE69525362E51BFA16(6404670),Status=Active,numRepliesOwedMe=0,numRepliesOwedOthers=0,seconds since begin=299,seconds left=60,activeThread=Thread[ExecuteThread: '22' for queue: 'weblogic.kernel.Default',5,Thread Group for Queue: 'weblogic.kernel.Default'],XAServerResourceInfo[weblogic.jdbc.wrapper.JTSXAResourceImpl]=(ServerResourceInfo[weblogic.jdbc.wrapper.JTSXAResourceImpl]=(state=started,assigned=none),xar=weblogic.jdbc.wrapper.JTSXAResourceImpl@a68c0),SCInfo[Mizuho-RWS+myserver]=(state=active),properties=({weblogic.jdbc=t3://10.104.8.81:7001}),OwnerTransactionManager=ServerTM[ServerCoordinatorDescriptor=(CoordinatorURL=myserver+10.104.8.81:7001+Mizuho-RWS+t3+, XAResources={},NonXAResources={})],CoordinatorURL=myserver+10.104.8.81:7001+Mizuho-RWS+t3+)]'. No further JDBC access is allowed within this transaction.
         at weblogic.jdbc.wrapper.JTSConnection.checkIfRolledBack(JTSConnection.java:118)
         at weblogic.jdbc.wrapper.JTSConnection.checkConnection(JTSConnection.java:127)
    Any inputs regarding this problem?

    Raghu S wrote:
    Hi,
    I am using WebLogic 8.1 SP2 on a Solaris machine.Ok, good enough. Once WebLogic times out a transaction, it rolls it back on the
    connection. That Sybase driver's rollback doesn't unfortunately affect it's
    own running statements. For 81sp3 we added code to explicitly cancel any ongoing
    statement during a rollback. This may be what you need to free up those
    threads and the socekts the driver may be keeping open. If you can upgrade
    to a newer version of 8.1, this code will free you up. Alternately, you can
    try either upgrading to Sybase'e latest driver or to our BEA driver for Sybase.
    Ask support for the latest BEA driver package for 8.1.
    Joe
    >
    Stacktrace of one of the threads at the time I took the thread dump....All the threads at the time of taking the thread dump are stuck in a similar fashion.
    ExecuteThread: '3' for queue: 'weblogic.kernel.Default'" daemon prio=5 tid=0x00883a90 nid=0x10 runnable [6d080000..6d0819c0]
    at java.net.SocketInputStream.socketRead0(Native Method)
    at java.net.SocketInputStream.read(SocketInputStream.java:129)
    at com.sybase.jdbc2.timedio.RawDbio.reallyRead(RawDbio.java:202)
    at com.sybase.jdbc2.timedio.Dbio.doRead(Dbio.java:243)
    at com.sybase.jdbc2.timedio.InStreamMgr.readIfOwner(InStreamMgr.java:512)
    at com.sybase.jdbc2.timedio.InStreamMgr.doRead(InStreamMgr.java:273)
    at com.sybase.jdbc2.tds.TdsProtocolContext.getChunk(TdsProtocolContext.java:561)
    at com.sybase.jdbc2.tds.PduInputFormatter.readPacket(PduInputFormatter.java:229)
    at com.sybase.jdbc2.tds.PduInputFormatter.read(PduInputFormatter.java:62)
    at com.sybase.jdbc2.tds.TdsInputStream.read(TdsInputStream.java:81)
    at com.sybase.jdbc2.tds.TdsInputStream.readUnsignedByte(TdsInputStream.java:114)
    at com.sybase.jdbc2.tds.Tds.nextResult(Tds.java:1850)
    at com.sybase.jdbc2.jdbc.ResultGetter.nextResult(ResultGetter.java:69)
    at com.sybase.jdbc2.jdbc.SybStatement.nextResult(SybStatement.java:204)
    at com.sybase.jdbc2.jdbc.SybStatement.nextResult(SybStatement.java:187)
    at com.sybase.jdbc2.jdbc.SybStatement.executeLoop(SybStatement.java:1698)
    at com.sybase.jdbc2.jdbc.SybStatement.execute(SybStatement.java:1690)
    at com.sybase.jdbc2.jdbc.SybCallableStatement.execute(SybCallableStatement.java:129)
    at weblogic.jdbc.wrapper.PreparedStatement.execute(PreparedStatement.java:68)
    at com.mizuho.rws.report.business.dao.FIReportsDAO.getReportList(FIReportsDAO.java:3463)
    at com.mizuho.rws.report.business.businessObject.FIReports.getReportList(FIReports.java:98)
    at com.mizuho.rws.report.business.ejb.FIReportsBean.getReportList(FIReportsBean.java:96)
    at com.mizuho.rws.report.business.ejb.FIReports_4f92ds_EOImpl.getReportList(FIReports_4f92ds_EOImpl.java:270)
    at com.mizuho.rws.report.client.delegates.FIReportsBusinessDelegates.getReportList(FIReportsBusinessDelegates.java:173)
    at com.mizuho.rws.report.client.web.FIReportsAction.handleFIReportsBean(FIReportsAction.java:1759)
    at com.mizuho.rws.report.client.web.FIReportsAction.performAction(FIReportsAction.java:349)
    at com.mizuho.foundation.presentation.AppBaseAction.perform(AppBaseAction.java:143)
    at com.mizuho.foundation.presentation.AppActionServlet.processActionPerform(AppActionServlet.java:518)
    at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1586)
    at com.mizuho.foundation.presentation.AppActionServlet.doPost(AppActionServlet.java:562)
    at com.mizuho.foundation.presentation.AppActionServlet.doGet(AppActionServlet.java:544)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run(ServletStubImpl.java:971)
    at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:402)
    at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:305)
    at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:6350)
    at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:317)
    at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:118)
    at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:3635)
    at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2585)
    at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:197)
    at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:170)
    And the stack trace of the exception I recieved.
    java.sql.SQLException: The transaction is no longer active - status: 'Marked rollback. [Reason=weblogic.transaction.internal.TimedOutException: Transaction timed out after 299 seconds
    Xid=BEA1-11FE69525362E51BFA16(6404670),Status=Active,numRepliesOwedMe=0,numRepliesOwedOthers=0,seconds since begin=299,seconds left=60,activeThread=Thread[ExecuteThread: '22' for queue: 'weblogic.kernel.Default',5,Thread Group for Queue: 'weblogic.kernel.Default'],XAServerResourceInfo[weblogic.jdbc.wrapper.JTSXAResourceImpl]=(ServerResourceInfo[weblogic.jdbc.wrapper.JTSXAResourceImpl]=(state=started,assigned=none),xar=weblogic.jdbc.wrapper.JTSXAResourceImpl@a68c0),SCInfo[Mizuho-RWS+myserver]=(state=active
    ),properties=({weblogic.jdbc=t3://10.104.8.81:7001}),OwnerTransactionManager=ServerTM[ServerCoordinatorDescriptor=(CoordinatorURL=myserver+10.104.8.81:7001+Mizuho-RWS+t3+, XAResources={},NonXAResources={})],CoordinatorURL=myserver+10.104.8.81:7001+Mizuho-RWS+t3+)]'. No further JDBC access is allowed within this transaction.
    at weblogic.jdbc.wrapper.JTSConnection.checkIfRolledBack(JTSConnection.java:118)
    at weblogic.jdbc.wrapper.JTSConnection.checkConnection(JTSConnection.java:127)
    at weblogic.jdbc.wrapper.Statement.checkStatement(Statement.java:222)
    at weblogic.jdbc.wrapper.PreparedStatement.setString(PreparedStatement.java:414)
    at com.mizuho.rws.services.mail.business.dao.FIReportMailDAO.insertMailClientDetails(FIReportMailDAO.java:2790)
    at com.mizuho.rws.services.mail.business.businessObject.FIReportMail.sendMail(FIReportMail.java:645)
    at com.mizuho.rws.services.mail.business.ejb.MailerBean.sendFIReportMail(MailerBean.java:87)
    at com.mizuho.rws.services.mail.business.ejb.Mailer_fyyt2g_EOImpl.sendFIReportMail(Mailer_fyyt2g_EOImpl.java:662)
    at com.mizuho.rws.services.mail.client.delegates.MailerBeanBusinessDelegates.sendFIReportMail(MailerBeanBusinessDelegates.java:153)
    at com.mizuho.rws.services.mail.business.businessObject.SendMailHandler.sendFIReportMail(SendMailHandler.java:181)
    at com.mizuho.rws.services.mail.business.businessObject.SendMailHandler.resolveMail(SendMailHandler.java:429)
    at com.mizuho.rws.services.mail.business.businessObject.SendMailHandler.notify(SendMailHandler.java:651)
    at com.mizuho.foundation.utils.AppNotificationListener.handleNotification(AppNotificationListener.java:66)
    at weblogic.time.common.internal.TimerListener$1.run(TimerListener.java:48)
    at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:317)
    at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:118)
    at weblogic.time.common.internal.TimerListener.deliverNotification(TimerListener.java:44)
    at weblogic.management.timer.Timer.deliverNotifications(Timer.java:578)
    at weblogic.time.common.internal.TimerNotification$1.run(TimerNotification.java:118)
    at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:317)
    at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:118)
    Regards
    Raghu

  • [b]How to convert a Socket object in a C socket file descriptor[/b]

    Hi all,
    I need to make a getsockopt() call using JNI, but I don't know how to convert a Java Socket object in the integer corresponding to the socket file descriptor.
    Thank you in advance!
    Fernando

    I was wrong in my previous post. FileDescriptor is used for PlainSocketImpl. This means I can give you a solution.
    The solution does involve rebuilding some built-in Java classes to make certain fields accessible.
    You have to modify access to three classes:
    1. You can either use my SocketGetImpl or just rebuild java.net.Socket and change from
    SocketImpl getImpl() throws SocketException {
    to
    public SocketImpl getImpl() throws SocketException {
    2. In java.net.SocketImpl change from
    protected FileDescriptor getFileDescriptor() {
    to
    public FileDescriptor getFileDescriptor() {
    3. In java.io.FileDescriptor I would add the method
    public int getFd(){ return fd; }
    Then my test program becomes:
    package myhack;
    import java.io.*;
    import java.net.*;
    public class DoSock {
            public static void main(String args[]) throws Exception{
                    Socket s= new Socket("mywebserver",80);
                    System.out.println("s="+s);
                    SocketImpl si = SocketGetImpl.getImpl(s);
                    System.out.println("si="+si);
                    FileDescriptor fd = si.getFileDescriptor();
                    System.out.println("fd="+fd);
                    System.out.println("fd int="+fd.getFd());
    }And you still have to invoke as:
    java -Xbootclasspath/p:. myhack.DoSock
    or boot path pointing at jar file, etc.

  • Tracking leaking file descriptors in java 6

    We migrated to java 6 .11 and immediately started noticing leaking file descriptors of TCP type (sockets) in Linux environment. We don't have this behavior with java 5 therefore i'm assuming something is wrong with java.
    Can you suggest how we can track this down ? The profilers seem to indicate the growing number of java.net.sockets , but not where they are originate. Upgrading to java6 rel 12 doesn't seem to help.
    We're seeing this behaviour with one of our web services which is deployed in Jboss app server.
    Appreciate your help
    -Stan

    stanleyG wrote:
    After weeks of dancing around the issue for weeks, we narrowed it down to garbage collection. If we put System.gc() to run periodically , file descriptors get garbage collected properly . I've tried playing with the settings by using XX:+UseConcMarkSweepGC which seems to help a great deal while system is under stress. However when there is light activity.. the file descriptors grow again and eventually bring everything down.
    Any clues ? is there any way to make gc to perform full collection more often ?
    pls whelp !!!Simple. Your application is written incorrectly.
    You should not be using/relying on GC to do anything but manage memory. Your code must explicitly manage all other resources. Other such resources would include sockets, files and various other OS specific resources such as pipes, handles, memory mapped objects and even regular memory that is allocated in JNI.
    And the only reason it worked in 1.5 is because the rate and/or depth varied versus 1.6 - your app was wrong in 1.5 too.
    Increasing the rate and depth that GC collects would make your problem invisible but it would not alter the fact that your application is written incorrectly.

  • Transfering a file through Socket programming

    Hi all,
    I want to return a file from server to client through a socket. I tried using ObjectOutput Stream where in I returned a java.io.File from server. But at client side when I say file.getLeangth() it comes as 0 and if I try to assign FileInputStream on the object it throws an exception as the file not found as the path associated with the file will be of Server.
    So can anyone help as to how to transfer a file through socket programming???
    thx in advance
    MK

    java.io.File is NOT the contents of the file. It really just represents the path.
    If you want to transfer the file's contents, you'll have to use a FileInputStream or FileReader, read from it, and then write the bytes or chars on the wire.

  • Any socket programming sample program or API for transfer file?

    Do there any java socket programming sample program or API for transfer file ,list file and make directory from client side?
    Thank you

    http://forum.java.sun.com/thread.jspa?threadID=603685&tstart=0

  • Bad File Descriptor ERROR

    Hi Friends,
    Here is my scenario:
    while (INFINITE_LOOP) {
         1. Create eraser.db DB with enabling environment & no transaction in dir: /DB_DIR
         2. Create expire.db DB without enabling environment & no transaction in same dir: /DB_DIR
         3. Perform add - remove record operations on both dbs.
         3. Close both dbs & environment
         4. Remove entire directory : /DB_DIR (using posix rmdir & unlink apis)
         5. sleep for 2 mins. (This is for stress testing... actual sleep value is 24 hrs)
    This while loop works for few iterations. But after few iterations I start getting below errors:
    seek: 0: (0 * 4096) + 0: Bad file descriptor
    eraser.db: write failed for page 0
    eraser.db: unable to flush page: 0
    seek: 4096: (1 * 4096) + 0: Bad file descriptor
    eraser.db: write failed for page 1
    eraser.db: unable to flush page: 1
    seek: 8192: (2 * 4096) + 0: Bad file descriptor
    eraser.db: write failed for page 2
    eraser.db: unable to flush page: 2
    Once these errors start occuring. All the db operations start failing for all the following iterations.
    Now I have to stop my program & restart, then only db starts working as expected.
    Kindly suggest the root cause of the problem.
    Regards,
    ~ Ashish K.

    Hi Friends,
    The above mentioned issues was not related to BDB. Finally I found "opened once, but closed twice" file descriptor issue in my multi threaded code.In our code a socket descriptor was getting closed twice. After few iterations of running, this problem was unintentionally leading to closing of one of the internal file descriptor of BDB. Once I fixed that problem. BDB started working as expected.
    For those who are unfamiliar to closing twice issue in multi threaded code read below:
    foo ()
        fd = open();
        // some processing.
        close (fd);
        // some processing.
        close (fd);
    The above code will work smoothly for a single threaded application. But in our case of multithreading, if a thread "X" call open(), when thread "Y" is in between the two close() calls, then in that case, thread "X" will get the same fd for open which thread "Y" was using (since open always return the smallest unused descriptor). File descriptors are shared by all the threads. So when thread "Y" carries out its second close(), it actually closes the file descriptor of thread "X", which was valid & in use.
    This is what precisely happening with my code.
    TIP: Whenever your multi threaded code, starts giving BDB errors like "Bad file descriptor" first check if there is a place in code where you are "opening once but closing twice" any file descriptor.
    Regards,
    ~ Ashish K.

  • Genunix: basic rctl process.max-file-descriptor (value 256) exceeded

    Hi .,
    I am getting the following error in my console rapidly.
    I am using Sun Sparc server running with Solaris 10 ., We start getting this error
    suddently after a restart of the server and the error is continously rolling on the console...
    The Error:
    Rebooting with command: boot
    Boot device: disk0 File and args:
    SunOS Release 5.10 Version Generic_118822-25 64-bit
    Copyright 1983-2005 Sun Microsystems, Inc. All rights reserved.
    Use is subject to license terms.
    Hardware watchdog enabled
    Failed to send email alert for recent event.
    SC Alert: Failed to send email alert for recent event.
    Hostname: nitwebsun01
    NOTICE: VxVM vxdmp V-5-0-34 added disk array DISKS, datype = Disk
    NOTICE: VxVM vxdmp V-5-3-1700 dmpnode 287/0x0 has migrated from enclosure FAKE_ENCLR_SNO to enclosure DISKS
    checking ufs filesystems
    /dev/rdsk/c1t0d0s4: is logging.
    /dev/rdsk/c1t0d0s7: is logging.
    nitwebsun01 console login: Nov 20 14:56:41 nitwebsun01 genunix: basic rctl process.max-file-descriptor (value 256) exceeded by process 439
    Nov 20 14:56:41 nitwebsun01 genunix: basic rctl process.max-file-descriptor (value 256) exceeded by process 414
    Nov 20 14:56:41 nitwebsun01 genunix: basic rctl process.max-file-descriptor (value 256) exceeded by process 413
    Nov 20 14:56:41 nitwebsun01 genunix: basic rctl process.max-file-descriptor (value 256) exceeded by process 414
    Nov 20 14:56:41 nitwebsun01 genunix: basic rctl process.max-file-descriptor (value 256) exceeded by process 413
    Nov 20 14:56:41 nitwebsun01 genunix: basic rctl process.max-file-descriptor (value 256) exceeded by process 121
    Nov 20 14:56:41 nitwebsun01 genunix: basic rctl process.max-file-descriptor (value 256) exceeded by process 414
    Nov 20 14:56:41 nitwebsun01 genunix: basic rctl process.max-file-descriptor (value 256) exceeded by process 413
    Nov 20 14:56:41 nitwebsun01 genunix: basic rctl process.max-file-descriptor (value 256) exceeded by process 121
    Nov 20 14:56:41 nitwebsun01 last message repeated 1 time
    Nov 20 14:56:43 nitwebsun01 genunix: basic rctl process.max-file-descriptor (value 256) exceeded by process 470
    Nov 20 14:56:43 nitwebsun01 genunix: basic rctl process.max-file-descriptor (value 256) exceeded by process 467
    Nov 20 14:56:44 nitwebsun01 genunix: basic rctl process.max-file-descriptor (value 256) exceeded by process 470
    Nov 20 14:56:44 nitwebsun01 genunix: basic rctl process.max-file-descriptor (value 256) exceeded by process 121
    Nov 20 14:56:44 nitwebsun01 last message repeated 1 time
    Nov 20 14:56:49 nitwebsun01 genunix: basic rctl process.max-file-descriptor (value 256) exceeded by process 503
    Nov 20 14:56:50 nitwebsun01 genunix: basic rctl process.max-file-descriptor (value 256) exceeded by process 510
    Nov 20 14:56:50 nitwebsun01 genunix: basic rctl process.max-file-descriptor (value 256) exceeded by process 121
    Nov 20 14:56:50 nitwebsun01 genunix: basic rctl process.max-file-descriptor (value 256) exceeded by process 519
    Nov 20 14:56:50 nitwebsun01 genunix: basic rctl process.max-file-descriptor (value 256) exceeded by process 516
    Nov 20 14:56:50 nitwebsun01 genunix: basic rctl process.max-file-descriptor (value 256) exceeded by process 519
    Nov 20 14:56:53 nitwebsun01 genunix: basic rctl process.max-file-descriptor (value 256) exceeded by process 540
    Nov 20 14:56:53 nitwebsun01 last message repeated 2 times
    Nov 20 14:56:53 nitwebsun01 genunix: basic rctl process.max-file-descriptor (value 256) exceeded by process 549
    Nov 20 14:56:53 nitwebsun01 last message repeated 4 times
    Nov 20 14:56:56 nitwebsun01 genunix: basic rctl process.max-file-descriptor (value 256) exceeded by process 665
    Nov 20 14:56:56 nitwebsun01 last message repeated 6 times
    Nov 20 14:56:56 nitwebsun01 genunix: basic rctl process.max-file-descriptor (value 256) exceeded by process 667
    Nov 20 14:56:56 nitwebsun01 last message repeated 2 times
    Nov 20 14:56:56 nitwebsun01 genunix: basic rctl process.max-file-descriptor (value 256) exceeded by process 121
    Nov 20 14:56:57 nitwebsun01 genunix: basic rctl process.max-file-descriptor (value 256) exceeded by process 868
    Nov 20 14:56:57 nitwebsun01 /usr/lib/snmp/snmpdx: unable to get my IP address: gethostbyname(nitwebsun01) failed [h_errno: host not found(1)]
    Nov 20 14:56:58 nitwebsun01 genunix: basic rctl process.max-file-descriptor (value 256) exceeded by process 887
    Nov 20 14:57:00 nitwebsun01 genunix: basic rctl process.max-file-descriptor (value 256) exceeded by process 976
    nitwebsun01 console login: root
    Nov 20 14:57:00 nitwebsun01 last message repeated 2 times
    Here I attached my /etc/project file also..
    [root@nitwebsun01 /]$ cat /etc/project
    system:0::::
    user.root:1::::
    process.max-file-descriptor=(privileged,1024,deny);
    process.max-sem-ops=(privileged,512,deny);
    process.max-sem-nsems=(privileged,512,deny);
    project.max-sem-ids=(privileged,1024,deny);
    project.max-shm-ids=(privileged,1024,deny);
    project.max-shm-memory=(privileged,4294967296,deny)
    noproject:2::::
    default:3::::
    process.max-file-descriptor=(privileged,1024,deny);
    process.max-sem-ops=(privileged,512,deny);
    process.max-sem-nsems=(privileged,512,deny);
    project.max-sem-ids=(privileged,1024,deny);
    project.max-shm-ids=(privileged,1024,deny);
    project.max-shm-memory=(privileged,4294967296,deny)
    group.staff:10::::
    [root@nitwebsun01 /]$
    Help me to came out of this issue
    Regards
    Suseendran .A

    This is an old post but I'm going to reply to it for future reference of others.
    Please ignore the first reply to this thread... by default /etc/rctladm.conf doesn't exist, and you should never use it. Just put it out of your mind.
    So, then... by default, a process can have no more than 256 file descriptors open at any given time. The likelyhood that you'll have a program using more than 256 files very low... but, each network socket counts as a file descriptor, therefore many network services will exceed this limit quickly. The 256 limit is stupid but it is a standard, and as such Solaris adheres to it. To look at the open file descriptors of a given process use "pfiles <pid>".
    So, to change it you have several options:
    1) You can tune the default threshold on the number of descriptors by specifying a new default threshold in /etc/system:
    set rlim_fd_cur=1024
    2) On the shell you can view your limit using 'ulimit -n' (use 'ulimit' to see all your limit thresholds). You can set it higher for this session by supplying a value, example: 'ulimit -n 1024', then start your program. You might also put this command in a startup script before starting your program.
    3) The "right" way to do this is to use a Solaris RCTL (resource control) defined in /etc/project. Say you want to give the "oracle" user 8152 fd's... you can add the following to /etc/project:
    user.oracle:101::::process.max-file-descriptor=(priv,8152,deny)
    Now log out the Oracle user, then log back in and startup.
    You can view the limit on a process like so:
    prctl -n process.max-file-descriptor -i process <pid>
    In that output, you may see 3 lines, one for "basic", one for "privileged" and one for "system". System is the max possible. Privileged is the limit by which you need to have special privs to raise. Basic is the limit that you as any user can increase yourself (such as using 'ulimit' as we did above). If you define a custom "priviliged" RCTL like we did above in /etc/projects it will dump the "basic" priv which is, by default, 256.
    For reference, if you need to increase the threshold of a daemon that you can not restart, you can do this "hot" by using the 'prctl' program like so:
    prctl -t basic -n process.max-file-descriptor -x -i process <PID>
    The above just dumps the "basic" resource control (limit) from the running process. Do that, then check it a minute later with 'pfiles' to see that its now using more FD's.
    Enjoy.
    benr.

  • Accpet() need more file descriptor

    my application server is using multithread to deal with high concurrency socket requests. When accpet() a request, it assign a FD, create a thread to deal, the thread will close the FD after finish the processing and thread_exit.
    my question is: when there are threads concurrency dealing 56~57 FDs, accept() can't get a new FD (errno.24). I know FD is limited in one process, I can try to fork sub_process to reach the high concurrency.
    But I wonder isn't there any other good method to solve the problem? How can a Web server reach a high concurrency?
    Any suggest is appreciated!
    Jenny

    Hi Jenny,<BR><BR>
    First of all, you did not say which release of Solaris you are using,<BR>but I'll assume you are on a version later than 2.4.<BR>
    You are correct when you say that the number of file descriptors <BR>
    that can be opened is a per-process limit. Depending on the OS <BR>version the default value for this limit changes, but there <BR>are simple ways to increase it.<BR>
    First of all there are two types of limits: a hard (system-wide) <BR>
    limit and a soft limit. The hard limit can only be changed by root<BR>
    but the soft limit can be changed by any user. There is one restriction<BR> on soft limits, they can never be set higher then the<BR>corresponding hard limit.<BR>
    1. Use the command ulimit(1) from your shell to increase the soft<BR>
    limit from its default value (64 before Solaris 8) to a specified <BR>value less than the hard limit.<BR>
    2. Use the setrlimit(2) call to change both the soft and hard limits.<BR> You must be root to change the hard limit though.<BR>
    3. Modify the /etc/system file and include the following line in <BR>
    to increase the hard limit to 128:<BR><BR>
    <CODE>set rlim_fd_cur=0x80</CODE><BR><BR>
    After changing the /etc/system file, the system should be rebooted <BR>so that the change takes effect.<BR><BR>
    Note that stdio routines are limited to using file descriptors <BR>
    0 through 255. Even though the limit can be set higher than 256, if<BR>the fopen function cannot get a file descriptor lower than 256,<BR>then it will fail. This can be a problem if other routines <BR>use the open function directly. For example, if 256 files are<BR>
    opened with the open function and none of them are closed, no other<BR>files can be opened with the fopen function because all of<BR>the low-numbered file descriptors have been used.<BR>
    Also, note that it is somewhat dangerous to set the fd limits higher<BR>than 1024. There are some structures, such as fd_set in<BR> <sys/select.h>, defined in the system that assume the maximum fd is<BR>1023. If a program uses an fd larger than 1023 with the macros<BR>and routines that access such a structure, the program will<BR>corrupt its memory space because it will modify memory outside<BR>of the bounds of the structure.<BR><BR>
    Caryl<BR>
    Sun Developer Technical Support<BR>

  • "IOException: Bad file descriptor" thrown during readline()

    I'm working on a system to send data to bluetooth devices. Currently I have a dummy program that "finds" bluetooth devices by listening for input on System.in, and when one is found, the system sends some data to the device over bluetooth. Here is the code for listening for input on System.in
    InputStreamReader isr = new InputStreamReader(System.in);
    BufferedReader br = new BufferedReader(isr);
    boolean streamOpen = true;
    while(streamOpen) {
         String next = "";
         System.out.println("waiting for Input: ");
         try {
              next = br.readLine();
               // other code here
          } catch (IOException ioe) {
               ioe.printStackTrace();
    } // end of whileThis is running in it's own thread, constantly listening for input from System.in. There is also another thread that handles pushing the data to the bluetooth device. It works the first time it reads input, then the other thread starts running also, printing output to System.out. When the data has successfully been pushed to the device, the system waits for me to enter more information. As soon as I type something and press return, i get an endless (probably infinte if I don't kill the process) list of IOExceptions:Bad file descriptor exceptions that are thrown from the readline() method.
    Here is what is being printed:
    Waiting for Input: // <-- This is the thread listening for input on System.in
    system started with 1 Bluetooth Chip // From here down is the thread that pushing data to the BT device
    next device used 0
    default device 0000000000
    start SDP for 0000AA112233
    *** obex_push: 00:00:AA:11:22:33@9, path/to/file.txt, file.txt
    I'm not even sure which line it's trying to read when the exception gets thrown, whether it's the first line after "Waiting for Input: " or it's the line where I actually type something and hit return.
    Any ideas why this might be happening? Could it have something to do with reading from System.in from a thread that is not the main thread?
    Also, this is using java 1.6

    Actually, restarting the stream doesn't work either..... here's a sample program that I wrote.
    public class ExitListener extends Thread {
         private BufferedReader br;
         private boolean threadRunning;
         public ExitListener(UbiBoardINRIA ubiBoard) {
              super("Exit Listener");
              threadRunning = true;
              InputStreamReader isr = new InputStreamReader(System.in);
              br = new BufferedReader(isr);
         public void run() {
              while (threadRunning) {
                   try {
                        String read = br.readLine();
                        if (read.equalsIgnoreCase("Exit")) {
                             threadRunning = false;
                   } catch (IOException ioe) {
                        System.out.println("Can you repeat that?");
                        try {
                             br.close();
                             br = new BufferedReader(new InputStreamReader(System.in));
                        } catch (IOException ioe2) {
                             ioe2.printStackTrace();
                             System.out.println("Killing this thread");
                             threadRunning = false;
                   } // end of catch
         } // end of run
    }output:
    I'm sorry, can you repeat that command? - Stream closed
    Closed Stream
    Ready?: false
    I'm sorry, can you repeat that command? - Stream closed
    Closed Stream
    Ready?: false
    I'm sorry, can you repeat that command? - Stream closed
    Closed Stream
    Ready?: false
    I'm sorry, can you repeat that command? - Stream closed
    Closed Stream
    Ready?: false
    I know that this is probably not enough code to really see the problem, but my main question is what could be going on somewhere else in the code that could cause this BufferedReader to not be able to re-open

  • TCP/IP socket programming in ABAP

    Hi,
    Is there any method of TCP socket programming in ABAP? For example is there any function module for creating a socket for a IP address and port number. After that, is it possible to send binary/text data to a connected IP/port destination. I need such a solution because I need to send raw data (native commans) to barcode printer on our network which has a static IP address and listens incoming data through a fixed port number specified in its documentation. For a solution, I coded some .NET VB and built a small application that acts as a RFC server program which can be called by SAP according to definitions I made in SM59 (I defined a new TCP connection and it works well sometimes!). In this application, data coming from SAP are transferred to the barcode printer. This is achived by the .NET Socket class library. This solution works well but after a few subsequent call from SAP, connection hangs! SAP cannot call the application anymore, I test the connection in SM59 and it also hangs, so I need to restart the VB application, but this is unacceptable in our project.
    As a result, I decided to code the program that will send data to the printer in ABAP as a function module or subroutine pool, so is there any way to create a socket in ABAP and connect to specific IP/port destination? I searched for possible function modules in SE37 and possible classes in SE24 but unfortunately I could not find one. For example, do know any kind of system function in ABAP (native commands executed by CALL statement), that can be used for this purpose?
    I would appreciate any help,
    Kind regards,
    Tolga
    Edited by: Tolga Togan Duz on Dec 17, 2007 11:49 PM

    Hi,
    I doubt that there is a low level API for sockets in ABAP. There is API for HTTP but probably that won't help you. As a workaround you can use external OS commands (transactions SM69 and SM49). For example on Unix you can use netcat to transfer file. Your FM needs to dump data into folder and then call netcat to transfer file.
    Cheers

  • [Urgent]3G Socket programming

    May I use socket for 3G networks?
    I use the demo provided by the WTK2.5-Beta(NetworkDemo), it works well in the simulator. However, when I download the program to the mobile phone, it seems that the mobile phone that runs ServerSocket cannot create the socket ... all the 2 handsets use a 3G SIM card provided by a Hong Kong ISP smartTone ... What can I do?
    Please help~ provide any web page of codes, thanks very much!

    1.     We want to create a socket connection which can
    remain open and live for ever till it is closed. Is
    this possible in java socket programming?Yes, but it isn't practical in the real networking world. So your code had better be prepared to deal with network failures.
    2.     I am just wondering in order to communicate with
    the third party over the socket connection, does this
    other party requires to run something specific on
    their end? I am not able to understand how will my
    java code communicate with their server otherwise.It has nothing to do with java. Sockets send and recieve messages. The applications at either end, regardless of the language that they are written in, must handle those messages.
    3.     Can we send and receive data over the socket
    created and also is their specific format for the
    data? Yes.
    Can we send files of data over this connection?Yes. (Although I don't know why you would need to do that if you are doing credit card auths.)
    It would be great if someone can comment on these
    questions and also if possible please provide some
    code that can create socket connection.The tutorial.....
    http://java.sun.com/docs/books/tutorial/networking/sockets/index.html

Maybe you are looking for

  • Can't find oraclient9.dll

    Hello, i try to connect me (NT workstation) to an Oracle Server. There are no errors in my code (i downloaded all needed classes from oracle.com), but i don't know what i have to install supplementary, because there are still problems. I get several

  • Windows server2012

    Dear sir,        Pleasant Morning sir, I have some queries please clarify the issues and do needful for us.  I have been installed the windows 2012 server R2 versions in that server need to assign the domain name. Already i have the same domain name

  • Print screen for mac with windows

    Hi.. can anyone tell me what is the print sreen key on mac using windows? thank you

  • IR Job Parameters - Import bqy to a location - Append date to filename - How to change the date format?

    Hi All, The title pretty much says it all. We have a few jobs running that require Mon-YY appended for each month they are run. Right now it's a manual process of changing the import file name in the parameters for each month. I see that I could appe

  • Could not find the Adobe Content Viewer.

    I have CS6 on my machine and when I try to preview a Folio on my desktop I get the prompt: An error occurred while generating folio preview. Could not find the Adobe Content Viewer. I have Adobe Air installed. Does anyone have any recommendations for